Ubuntu – How to reset default permissions for /etc?


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  

Best Answer

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.*/*
chmod 400 /etc/ssh/ssh*key

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

Related Question