0

By error I set all folders and files permissions on 775, executing this command

sudo chmod 775 -R /website/folder /

And now I need to restore all the server folders and paths permissions at least centos files, by the moment I can't send emails from my websites...

System is centos 5

Thanks...

glglgl
  • 89,107
  • 13
  • 149
  • 217
Chris
  • 33
  • 1
  • 8

2 Answers2

0

I am not aware of a way to undo this automatically. The only solutions that I am aware of are to manually fix the critical permissions, or to restore from backup. If I were you, I'd just restore from backup assuming that you have a good recent backup.

jncraton
  • 9,022
  • 3
  • 34
  • 49
  • Hi jncranton, actually I don't have a backup. And by the moment I need at least restore the emails send... :( – Chris Jun 04 '12 at 16:27
0

This is not meant as a complete solution, but rather as a idea how to solve this.

You could query the packet database (in CentOS it is AFAIR RPM) and set the permissions the way they are meant to be according to that database.

Some helpful commands for RPM:

  • rpm -Va verifies the files registered in the RPM database. Files which have the wrong permissions are listed there. Files with the wrong mode are displayed with a M in the 2nd column. So something like rpm -Va | grep ^.M | cut -c 13- should be a good start.

  • Another option could be to query all files in all packets with

    rpm --queryformat='%{FILEMODES}\t%{FILENAMES}\n' -qa
    

    and process the output by piping it into some kind of loop such as

    | while read mode fn; do chmod -V ... "$fn"; done
    

    but here you would have to convert the decimal output from FILEMODES to octal so that chmod understands it.

    Alternatively, you could process the output with something else, like a python script or so, which gives you much finer control over what you do.

glglgl
  • 89,107
  • 13
  • 149
  • 217