Monday 24 March 2014

Accidentally Locked Yourself out of the sudoers group?

Have you accidentally locked yourself out of the sudoers group? Don't worry, here's a way to fix it.

If you don't have a root user that you could use to log in with to fix this issue, so. 
what you have to do is boot in single user mode, which would give you root permissions and then add yourself back to the sudoers group.

To do this, you could reboot and select the "Recover" option,
OR
Once in the GRUB screen, select the Linux entry and press 'e' to edit that entry.
Then, go to the end of the line that starts with 'Linux' and add a single '1'.
Now press Control-x to boot.
You will get a prompt asking for your root password. If you're using Ubuntu and don't have a root account, you simply press Enter and you're in. 
OR
Just 'su' your way back to the sudoers group
Once you are logged as root execute:
usermod -aG sudo <youruser>
Run 'visudo' and make sure you have the proper line added for your user as look like below.

user ALL=(ALL:ALL) ALL

Once you finished, save and close the editor (Esc, ':q!') and press Ctrl-d to restart the system.

No comments:

Post a Comment