Linux: Set permission only to directories
bash, chmod, directory, linux
Solution
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 {} +
Problem
I have to change the permissions of the `htdocs` 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 `htdocs`, 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?