Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


I am not able to add any users to the sudo users as my sudoers file has the wrong permission. My only access is SSH thus this(via recovery mode) solution doesn't seem to work for me.

I will be grateful for any idea. My ubuntu is 9.04 server edition.


user@server:~$ sudo nano /etc/sudoers 
sudo: /etc/sudoers is mode 0640, should be 0440
Segmentation fault

user@server:~$ sudo chmod 0440 /etc/sudoers 
sudo: /etc/sudoers is mode 0640, should be 0440
Segmentation fault
share|improve this question
Unfortunately if you have no other way to login as root (ie an SSH account open with pubkey auth or a password defined for root to be able to su into it) you have no other way than to request someone with physical access to boot into recovery mode and do the fix. – François Feugeas Aug 26 '10 at 9:06
defraagh true, or wait for a root exploit to emerge ;) – Joris Aug 26 '10 at 10:17

You need to log in as root, because you will not be able to use sudo until you fixed it. If you have set a root password, type su and go ahead. If not, you need some kind of rescue system or the possibility to change the kernel parameters in grub.

Are you able to boot into a rescue system? Then mount your root filesystem somewhere and change the permissions of the file to 0440.

Are you able to change the kernel options? then add init=/bin/sh to it and boot. When the prompt appears, change your password like this:

# mount -o remount,rw /
# passwd
# mount -o remount,ro /
# reboot

Then boot up your server and get root with su. Disable the root password afterwards

A third option would be to use security leaks in your system to become root. But I can't and don't want to help you there

share|improve this answer
I was going to suggest those at first, but then I realized his only way to reach the server is via ssh. That complicates this issue a lot (unless he has enabled root account reachable via su ...). – Janne Pikkarainen Aug 26 '10 at 9:18
@Janne: You should still post your warning about using visudo (at least as a comment below the question). – Dennis Williamson Aug 26 '10 at 14:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.