I messed around with the
sudoers file without really knowing what I was doing using this link.
Assume I did everything that was in the top answer along with editing it with
vim and not
visudo. How do I fix this?
I’m running Xubuntu 12.04, and I didn’t set a root password.
Here is Solutions:
We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.
The easiest fix is to boot from a Live CD, then mount your local drive and edit or revert to the old
Boot from a live CD
/partition. Open a terminal and run
sudo fdisk -lor
blkidand identify your root (
/) partition. For this example, I will assume it is
Mount your root partition to a temporary location
sudo mkdir /foo sudo mount /dev/sda /foo
Now that the partition is mounted, check the
/foo/etcdirectory. You probably have a file called
/etc/sudoers~which is a backup of your
sudoersfile. If so, this will probably solve everything:
sudo cp /foo/etc/sudoers~ /foo/etc/sudoers
If that doesn’t work, just edit the file and revert your changes as best you can (or add it to your question and we can help you out with it). If you introduced lines with a syntax error, remove them or comment them out by adding
#at the beginning. If you removed the line that granted you sudo powers, it was probably like this (where
sudois a group that your user is in, i.e. your username is mentioned on the line in
/etc/groupthat begins with
%sudo ALL=(ALL:ALL) ALL
Take the CD out and reboot.
Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂