Linux – Change ownership or permissions on only directories or files, recursively

linuxpermissions

I'm trying to set permissions/ownership on either directories or files, recursively within a given directory, without changing the other.

E.g. I have directory /web where I want to set all the directories to 775, but the files to 664.

Is there a way to do this easily?

Best Answer

For files:

$ find /path/to/directory -type f -print0 | xargs -0 chmod 664

For directories:

$ find /path/to/directory -type d -print0 | xargs -0 chmod 775