Recursively change file permissions

If you chmod -R it will recursively chmod everything whether it be a file or directory. A more sensible way is:

# Change directories
find . -type d -exec chmod 755 {} \;

# Change files
find . -type f -exec chmod 644 {} \;

Obviously chowning is similar:
find . -type f -exec chown user:group {} \;

Find is also useful in directories with a very large number of files, where a standard chmod/chown may time out.

find . -name “*.gif” -exec chown apache:apache ‘{}’ \;

You can leave a response, or trackback from your own site.

Leave a Reply