Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

By mistake I have made permission changes for /etc. Now it's giving me the following error message:

bash: /etc/bash.bashrc: Permission denied  
I have no name!@chandan-Inspiron-5520:~$ sudo /etc/init.d/apache2 restart  
sudo: unable to stat /etc/sudoers: Permission denied  
sudo: no valid sudoers sources found, quitting  
sudo: unable to initialize policy plugin  
share|improve this question
    
related: askubuntu.com/questions/115358/… –  Kevin Bowen Jun 16 '13 at 23:23
add comment

3 Answers

As a next step after sputnik recommendation, you could do this: On a fresh install of a ubuntu server with the same version as your broken one, run this:

find /etc -type f -executable | awk '{printf("chmod a+x %s\n",$0);}' > setexec.sh

Then import the script setexec.sh (using wget or ftp) and execute it on the broken server. on ubuntu 13.04 this step restored most of the functionalities.

share|improve this answer
add comment

What I would do :

$ sudo su
# chown -R root:root /etc
# find /etc -type f -exec chmod 644 {} +
# find /etc -type d -exec chmod 755 {} +
# chmod 755 /etc/init.d/* /etc/rc.local /etc/network/* /etc/cron.*/*

Maybe it's not sufficient, but without any backup, that's a good start.

share|improve this answer
add comment
gksudo chown -R root:root /etc/
gksudo chmod -R u+x /etc/
gksudo chmod -R a+r /etc/

should work. This is will give read and execute permissions to everything in /etc/. gksudo doesn't depend on the sudoers file to work like regular sudo does. This will give you a working point to get everything else back.

share|improve this answer
add comment

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.