Search code examples
linuxchmodchown

Permissions safety check in linux?


What is the quickest way to check the permissions of several folders and files in /home to see if any accounts have permissions set to an unsafe value?

What would be considered unsafe?

  • files that have access levels that could potentially be written to from the public
  • read access to .htaccess, .svn, etc files
  • any files that may otherwise compromise the safety of the web server

EDIT

I think this is a two-part question. I've mentioned what I think is unsafe above, but perhaps it should also be asked: what else could make a site unsafe on a permissions level? What are the risk and how do you check for them?


Solution

  • Obvious answer:

    find -L /home -perm 0777
    

    Prints out all the files/directories with the mode 0777, typically a mode you don't want set.

    More specific:

    find -L /home -perm /o+w 
    

    All files/directories that can be written to by anyone.

    find -L /home -perm /o+r -name '.*' -type f
    

    All files that start with a . that can be read by anyone

    any files that may otherwise compromise the safety of the web server

    There's not going to be any comprehensive way of quickly determining this.