Recursively chmod Directories Only

23 May 2011 • 1 minute read

The find utility’s -exec flag makes it very easy to recursively perform operations on specific files or directories.

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

This command finds all directories (starting at ‘dot’ - the current directory) and sets their permissions to 755 (rwxr-xr-x).

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

Similarly, this command finds all files and sets their permissions to 644 (rw-r–r–).

Thanks to moveabletripe for the info.

(Read more)