Naturally, you always use visudo
to edit your /etc/sudoers
file because that
is safer.
But sometime you mess up anyway and lose root.
Thankfully, you can get back in... sometimes.
- Restart your machine
- Hold shift to enter grub on start up.
- Go to recovery
- Drop to root shell prompt
- Remount FS with "mount -o rw,remount /"
- Repair the sudo file or group. (When I wrote this I needed
usermod -a -G my_user_name sudo
)
Naturally, you should probably lock down your GRUB better than this, since this level of physical access to your machine should not automatically mean root.