Fixing file system permissions

Have you ever shelled into a file system where a bunch of files were executable that should not be? Or maybe permissions are generally a mess?

Typically within a website file system, files should be 644 (owner read/write, group & all just read) and directories should be 755 (owner read/write/execute, group and all just read/execute).

If you don't have any special needs for individual files to be executable, or you just want to start fresh, you can use this method.

The following commands first changes directories to the web root of my website. Then I recursively sets all files and directories to 644. After that, the find command is used to set all directories executable for user/group/all.

# cd /var/www/mywebsite/public_html# chmod -R 644 *# find . -type d -exec chmod uga+x {} \;