简体   繁体   中英

Linux recursive chmod only on sub-directories

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?

Off the top of my head:

find {folder} -type d -print0 | xargs -0 chmod 777

find {folder} -type d -print0 | xargs -0 chmod 777

Try:

find {folder} -type d -exec chmod 777 {} \;

Straight from the man pages :http://ss64.com/bash/chmod.html

And also corroborated here: https://stackoverflow.com/a/17091831/538512

use the following format or a derivative thereof chmod -R u=rwX,go=rwX {folder}

Hope that helps!

We can also run below command to change permission of all folders recursively.

sudo chmod 777 -v $(find $PWD -type d)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM