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
Following this post:
A black terminal should come up, at this point you can run this command (you should have root privileges):
chmod 0440 /etc/sudoers
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
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.
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
Jun 27, 2011 at 6:16
sudo
for the first, the second should be done from a Live CD.
Jun 27, 2011 at 7:03
chmod 0440 /etc/sudoers
without sudo as sudoers is writable by everybody?
Jun 27, 2011 at 7:46
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.
Boot into recovery mode, choose the root shell, and:
chmod 0440 /etc/sudoers
Or if you don't want to restart you can use this alternative:
pkexec chmod 0440 /etc/sudoers
pkexec chmod 0440 /etc/sudoers.d/README
it will change the permission. Try it it will work.
chmod
ing some files to 440
and others to 0440
? Shouldn't you use 0440
uniformly? And why are you changing permissions on /etc/sudoers.d/README
when you use the pkexec
way, but not otherwise? And what about other possible files in /etc/sudoers.d
?
Aug 23, 2012 at 14:12
What did you do to get these errors?
If you did: sudo chmod -R 777 /etc
, you need a Live CD to repair this.
/etc
if you've put /etc
on a separate partition). This can be done by using a file browser like Nautilus or the Places menuls -l /media
. It's possibly named ubuntu
or disk
. In the next steps, I'll assume ubuntu
.In the Terminal, set restrictive permissions by default:
sudo find /media/ubuntu/etc -type f -exec chmod g-wx,o-rwx {} \;
sudo find /media/ubuntu/etc -type d -exec chmod g-w,o-rwx {} \;
Next, use the Live CD as reference point for restoring file permissions. The below command will change the file permissions for /etc/media/ubuntu
using the /etc
folder on the Live CD as reference point. It'll only change permissions on files (-type f
) and directories (-type d
) on the same filesystem (-xdev
). Any errors are written to ~/errors.log
Errors like "file not found" indicates that a file on the system is installed, but not found on the Live CD. The command from step 5 should set the right permissions for it, but for the best results, you'd better reinstall the packages.
cd /media/ubuntu && sudo find etc -xdev \( -type f -o -type d \) -f -exec chmod --reference=/{} {} \; 2>~/errors.log
~/errors.log
somewhere (like http://paste.ubuntu.com/) so you can add it as comment to this answer should you've any problems with applications.In Ubuntu you can first strike Ctrl+Alt+T which opens the terminal. After that you can copy-paste the command below with Ctrl+C and paste in terminal with Ctrl+Shift+V.
pkexec chmod 0440 /etc/sudoers
For me, I had to add one more step the the pkexec
suggestions, per this, I was lucky that I happened to have 2 ssh sessions going when I made the stupid mistake:
echo $$
to get PIDpkttyagent --process PID_FROM_STEP2
in terminal 2pkexec chmod 0440 /etc/sudoers
pkexec chown root:root /etc/sudoers
/etc/sudoers.d/README
, that the error can still saysudo: /etc/sudoers is mode 0777, should be 0440
?