Recursively chmod files (or folders) only

Modifying permissions with chmod and using recursive -R tag is handy, but it will be executed on both, files and folders:

chmod -R 755 /path/to/directory

To change permissions on files (or folders) inside directory structure, we can use the following commands:

Files only

cd /path/to/directory
find . -type f -exec chmod 644 -- {} +

Folders only

cd /path/to/directory
find . -type d -exec chmod 755 {} +

Leave a Reply

Your email address will not be published. Required fields are marked *