Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am new in ubuntu, i am trying to run following command

sudo su -

Bu i am getting following message

sudo: unable to open /etc/sudoers: Permission denied
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

Previously it was running but when i run following command

chmod 741 /etc/

It is stop working, i don't have root user password, i am running my machine on Amazon.

Pls suggest me how can i fix this problem.

share|improve this question
    
With physical access, fixing this would be trivial. With only remote access, maybe a little less so. Does EC2 offer booting an instance into some sort of recovery mode (akin to single user mode)? If so, you may be able to use it. That said, I'd see if /etc (and only /etc) can be restored from backup. –  Michael Kjörling Apr 19 '13 at 13:51

3 Answers 3

Normal permissions for /etc/ are: rwx r-x r-x root root

Using chmod 741 /etc/ means to set the permissions /etc/ to rwx r-- --x.

Notice the lack of r in the third field. These three fields represent: Owner, group, others. Since the default owner and group is root you just prevented everyone except root from reading files in /etc/. This is a bad thingtm.

If you get a root prompt then you can revert these changes easily enough, but for that you need:

  • Either an already open root prompt.
  • A way to log in as root or any uid 0 account.(You need to manually set this in Ubuntu.)
  • Right to su or sudo (which you just broke).
  • Or access to the filesystem from another OS.
  • Or reinstall the system. (Easiest to do if you just set it up a few minutes ago, but also the least educative way)

For a normal desktop or a server with remote access card (HP ILO, Dells DRAC etc) I would boot into single user mode, provide the root password if needed, and fix the permissions.

Or I would boot from a liveCD (or pendrive) and do the same.

On Amazon this is a bit harder because you have no physical access. However you can start a second instance and mount your old OS disk from there.

share|improve this answer
    
"you just prevented everyone except root from reading files in /etc" No, the OP prevented file access by the root group and file enumeration by others. Note that on directories, "read" means reading the list of files in the directory, and "execute" means accessing files that you know the name of. For full useful read access one needs both, but I've been known to set up e.g. web hosting accounts with something like 0711. –  Michael Kjörling Apr 19 '13 at 13:57
pkexec chmod 0440 /etc/sudoers

Then try sudo -s

share|improve this answer
    
thanks for replay , but i don't have pkexec, when i used sudo apt-get install policykit-1 command to get it, it is again showing same error message. –  Pavan Tiwari Apr 19 '13 at 12:55

Execute command:ls -l /etc/sudoers If result shows zero hard link like below maybe your filesystem damaged:

-r--r----- 0 root root 1014 2013-19-4 17:40 /etc/sudoers

else read : http://www.psychocats.net/ubuntu/fixsudo

share|improve this answer
    
He just did a chmod 741 /etc/ (no r for others). That is the source of the problem, not FS damage, –  Hennes Apr 19 '13 at 13:16
1  
command should be like that ls -l /etc/sudoers –  pavan tiwari Apr 19 '13 at 13:18
    
My FS is not damaged -r--r----- 1 root root 584 2009-03-10 20:25 /etc/sudoers –  pavan tiwari Apr 19 '13 at 13:19
    
I forgot to write -l option, Thanks. –  Sepahrad Salour Apr 19 '13 at 13:19
    
If hard link is 1 Now read that link i posted. –  Sepahrad Salour Apr 19 '13 at 13:20

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.