I was going to modify my.conf file so I wanted to change its permissions, but I ran the code in the current dir instead of only the file

Now all files in the /etc (and the folders) have 777 permissions. Now when I run a terminal, it shows "/etc/bash.bashrc: Permission denied" error.

Also I was using proxy and now proxy is also does not work and I cannot reach to the internet from that machine.

I am using OpenSuse...

How can I fix all permissions?

  • Sorry pal, but setting up permissions in /etc is kinda messy. If you have a spare machine I would suggest to try to change de permissions, but maybe a reinstall would be easier... – Ivan Mar 8 '13 at 15:38
  • @Ivan: A reinstall is overkill, most files are 644, most directories 755. Only some files must be 600 (like /etc/shadow and /etc/ssh/ssh_host*) or 755 (like scripts in /etc/init.d and /etc/sysconfig/network/scripts/). – jaume Mar 8 '13 at 16:07
  • @jaume: thanks. I will try the answer first then yours – wakeup Mar 8 '13 at 16:45
  • Thanks, but my comment only says "don't panic!" and explains a quick repair, don't promote it to an answer :-) I'd recommend that you thoroughly repair permissions, either using Zhen's script below or by other means. – jaume Mar 8 '13 at 17:01

You need another similar machine with also OpenSuse (or install a Virtual Machine image). You should be able to do ssh against this image:

Put a simple script in this server, like (e.g: call it show_permission and put on the $HOME):

if [ -e $1 ]
   find $1 -printf "%m %p\n" 
   echo ERROR $1

Then, in your ill-server, you can execute this:

find /etc/ -exec ssh <IMAGE_SERVER> ./show_permission {} ";"

to get the permissions to restore. The lines that start with ERROR, will need manual fix.

With this command you will get a permission list of /etc files. Append chmod to all lines and execute. Double check it first, this time :D

  • This would work if he can access the machine. – Ivan Mar 8 '13 at 16:59
  • @Ivan, well. I didn't test it with a VM image, but its a good option to get a similar machine. – Zhen Mar 8 '13 at 17:03
  • Agreed, @Zhen, just not sure what is his condition: if he can ssh into the machine, if he has physical access, and if he has a spare machine. It seems to me that your script would work - and I gave it an upvote. – Ivan Mar 8 '13 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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