CHMOD folders, sub-folders, sub-sub-folders, and so on

If you recently changed your PHP handler to suPHP from mod_php or DSO, then you need to CHMOD all your folders, its sub-folders, sub-sub-folders, and so on to 744 to avoid any internal server errors, specifically internal server 500 errors.

And also, you need to CHMOD all of your files to 644.

In order to do this automatically, login as root in your server and go to your home directory, then enter this command via SSH.

For folders:
find {path to the folder} -type d -exec chmod 755 {} \;

For files:
find {path to the folder} -type f -exec chmod 644 {} \;

And that’s it! It will change the permissions of all your files and folders under your home directory automatically! It’s like magic!

If the above method doesn’t work for you, try the xargs method.

For folders:
find . -type d -print0 | xargs -0 chmod 0755

For files:
find . -type f -print0 | xargs -0 chmod 0644


Comments

3 responses to “CHMOD folders, sub-folders, sub-sub-folders, and so on”

  1. Thanks for the hint ๐Ÿ˜‰

    but I got a error saying find: missing argument to `-exec’
    so I solved it using this command: find -type d -exec chmod 755 {} \;

    1. Yep you just need to use a single backslash. ๐Ÿ˜€

  2. The xargs method did the trick! thanks

Leave a Reply to Steve Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.