How to Recursively chmod Directories or Files

Command to recursively chmod only directories:

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

How to recursively set the execute bit on every directory:

chmod -R a+X *

The +X flag sets the execute bit on directories only

How to recursively chmod only files:

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

How to recursively chmod only PHP files (only for PHP files with the extension .php):

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

You can change the “.php” in the line above to whatever file extension that you want.