I'm on linux, and I have a directory with numerous sub-directories and items inside them. I want to run a recursive chmod on all directories and sub-directories but NONE of the files inside those directories.
chmod -R 777 {folder}
Is there a flag I can add to the chmod command to make the chmod only apply to sub-directories?
Changing permissions with chmod To modify the permission flags on existing files and directories, use the chmod command ("change mode"). It can be used for individual files or it can be run recursively with the -R option to change permissions for all of the subdirectories and files within a directory.
Use chmod -R 755 /opt/lampp/htdocs if you want to change permissions of all files and directories at once. Use find /opt/lampp/htdocs -type d -exec chmod 755 {} \; if the number of files you are using is very large.
It is common to use the basic chmod command to change the permission of a single file. However, you may need to modify the permission recursively for all files within a directory. In such cases, the chmod recursive option ( -R or --recursive ) sets the permission for a directory (and the files it contains).
Off the top of my head:
find {folder} -type d -print0 | xargs -0 chmod 777
find {folder} -type d -print0 | xargs -0 chmod 777
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With