This question already has an answer here:

Consider a single user(with a root user) where the user doesn't know the password of the root user which disables him from using su root and who was in sudoers file but he himself removed him from the sudoers group with the commandsudo adduser foo sudo. Now, How does the user foo will access root privileges?

marked as duplicate by karel, Pilot6, David Foerster, Zanna, Kevin Bowen Mar 8 '17 at 14:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Sounds like you've locked yourself out of sudo privileges. You are going to need to boot to Grub recovery mode and access root shell.

  1. Go to Grub menu by pressing shift key upon startup.

  2. Select Ubuntu recovery mode and then root shell prompt

  3. Type in:

    mount -o rw,remount /

    and in the next line

    usermod -aG sudo username

    where username is your username.

  4. Exit and restart.

  5. Check the /etc/group file. Your username should now be in the sudo group.

As long as your user is in the sudo group, Sudoers file may be modified to give privileges to access root with sudo su command, providing that you know user's password.

Not the answer you're looking for? Browse other questions tagged or ask your own question.