radicaled radicaled - 1 year ago 87
Linux Question

Linux: Set permission only to directories

I have to change the permissions of the

directory in apache to a certain group and with certain read/write/execute.

The directories need to have 775 permissions and the files need to have 664.

If I do a recursive 664 to the
, then all files and directories will change to 664.

I don't want to change the directories manually.

Is there any way to change only files or directories?

Answer Source

Use find's -type option to limit actions to files and directories. Use the -o option to specify alternate actions for different types, so you only have to run find once, rather than separately for each type.

find htdocs -type f -exec chmod 664 {} + -o -type d -exec chmod 775 {} +
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download