sudo error, is mode 0777, should be 0440
I am getting sudo errors, how do I fix this error?
sudo: /etc/sudoers is mode 0777, should be 0440
sudo: no valid sudoers sources found, quitting
Solution 1:
First Option
Following this post:
- Reboot PC
- When the GRUB boot selection screen shows, choose Recovery Mode. (If it doesn't come up, press the Shift key when you see the GRUB loader down the bottom).
-
A black terminal should come up, at this point you can run this command (you should have root privileges):
chmod 0440 /etc/sudoers
Alternatively
You will have to put Ubuntu onto a LiveCD, boot into the LiveCD, mount your Ubuntu Partition on the Hard Drive (Open a file browser, like Nautilus, and click your Ubuntu Partition; or click Places->"xxGB Partition/Your Ubuntu Partition").
Then, open a terminal within the LiveCD session and type these two commands:
cd /media/<name of permanent ubuntu partition>/etc
sudo chmod 0440 sudoers
Extra Problems
If there are any errors (as posted below), follow the error prompt and adjust each file accordingly using one of the above two steps:
sudo apt-get update sudo: /etc/sudoers.d/README is mode 0777, should be 0440 sudo: /var/lib/sudo writable by non-owner (040777), should be mode 0700 [sudo] password for
Fix by following through with:
chmod 0440 /etc/sudoers.d/README
chmod 0700 /var/lib/sudo
Both of these commands should be used appropriately with the outlined steps above. They will change the file permissions associated with that file. 0440 will give the owner (root) and the group read permissions and 0700 will give the owner (root), read, write and execute permissions.
Solution 2:
sudo
is broken in this situation, but pkexec
(the command-line frontend to PolicyKit) still works, so you can fix it with a single command. No rebooting is necessary.
pkexec chmod 0440 /etc/sudoers
This assumes PolicyKit is installed. If this is a desktop system (rather than a server with no GUI), it is.