Changing permissions on directories or files only

This is here as a memory aid as I don’t have to do this very often so I end up trying to search for it.

To change the permissions of directories only

find /path/to/base/dir -type d -exec chmod 755 {} +

For files:

find /path/to/base/dir -type f -exec chmod 644 {} +

The key to this is the -type for the find command.

I once used to use find a great deal years ago but as I don’t do much admin the usage has slipped from my memory.

Leave a Reply

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