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

This will recursively search your directory tree (starting at dir ‘dot’) and chmod 755 all directories only.

Similarly, the following will chmod all files only (and ignore the directories):

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

Note: The {} gets replaced by the current file find is processing (which is why you don’t need to use chmod -R), and \; is just there to mark the end of the exec expression.

Also

''find . -type f -name '*.htm*' -exec chmod 644 {} \;''

to only apply chmod to files with names matching a specified pattern. Great when you need to clean up after a php application install and set php files to 755, html files to 644, etc..

Also the situation where the ‘user-owner’ permissions are correct, but the ‘other’ permissions have been made too restrictive, disallowing read access. The following command will fix it:

''chmod -R o+rX .''

Note that the capital ‘X’ causes it to do the right thing regarding the executable bit: directories will be executable and files will be made executable only if the file is executable for the ‘user-owner’ or ‘group-owner’. Check out the man page for chmod.

Another helpful command for changing files of only a specific type/extension is:

''find ./ -name *.pdf -exec chmod 755 {} \;''