Here is how to recursively use the command-line utility chmod
to change directory and file permissions in Linux and macOS easily. It combines the utilities find
and chmod
. I always use these popular techniques; I hope they help you.
These will recursively search the directory tree, starting at the current directory (‘dot
‘).
Example 1
Recursively chmod 755
, all directories only:
find . -type d -exec chmod 755 {} \;
Example 2
Recursively chmod 644
, all files only (and ignore the directories):
find . -type f -exec chmod 644 {} \;