Ever need to recursively set permissions only on files or folders in Linux/Unix?

One way to do it is with the find command.

For files, use -type f.  For directories, use -type d.

For example:

# RECURSIVELY CHMOD DIRECTORIES UNDER CURRENT PATH TO 750
find ./ -type d -exec chmod 750 {} \;

# RECURSIVELY CHMOD HTML FILES UNDER /home TO 640 find /home/ -type f -name '*.html' -exec chmod 640 {} \;

← Older Newer →

Leave a Reply

You must be logged in to post a comment.