Linux – How to do a recursive chmod only on directories

chmodlinux

I want to change permissions on a tree on Centos 4 to add execute permissions for all directories recursively from a directory. If I use normal chmod, files other than directories are also modified:

chmod -R o+x /my/path/here

How can I only affect directories?

Best Answer

Run find on -type d (directories) with the -exec primary to perform the chmod only on folders:

find /your/path/here -type d -exec chmod o+x {} \;

To be sure it only performs it on desired objects, you can run just find /your/path/here -type d first; it will simply print out the directories it finds.