How to rename sudoers back to its original naming? [duplicate]
Today I made a big mistake, I run the command
mv /etc/sudoers{,.bak}
on my ubuntu machine and now sudoers file is missing
This is the message given in terminal wherever I use sudo
sudo: unable to stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
How to make that backup file again back to normal and get back sudo
?
I think the fastest way to fix this would be to get a root shell from the recovery mode and to move the original /etc/sudoers
back in place:
- Hold LSHIFT (or ESC if LSHIFT doesn't work) at power-on to boot into
grub
; - Select the default kernel's recovery mode (e.g.
Ubuntu, with Linux 3.19.0-15-generic (recovery mode)
) and hit Enter; - Select
root - Drop to root shell prompt
and hit Enter; - Run
mount -o rw,remount /
; - Run
mv /etc/sudoers.bak /etc/sudoers
; - Run
reboot
;
Since Ubuntu also has pkexec
installed, and Polkit configuration is independent of sudoers
:
pkexec mv /etc/sudoers{.bak,}
Oh I've done this one before. :) oops...
-
Reboot using a LIVE CD (The one you installed Ubuntu with)
-
Choose the "Try Ubuntu" option NOT the "Install Ubuntu" option.
Once you are to the desktop just mount your main HDD (should show at the bottom left as a hard drive)
-
Launch the file manager and navigate to the
/etc/
folder on that newly mounted hard drive. -
Rename the
sudoers.bak
file tosudoers
.
Reboot and you should be good to go. Let me know if that helps.