简体   繁体   English

Linux 仅在子目录上递归 chmod

[英]Linux recursive chmod only on sub-directories

I'm on linux, and I have a directory with numerous sub-directories and items inside them.我在 linux,我有一个目录,里面有许多子目录和项目。 I want to run a recursive chmod on all directories and sub-directories but NONE of the files inside those directories.我想在所有目录和子目录上运行递归 chmod,但这些目录中的文件都没有。

chmod -R 777 {folder}

Is there a flag I can add to the chmod command to make the chmod only apply to sub-directories?有没有我可以添加到 chmod 命令的标志,使 chmod 仅适用于子目录?

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 {} \;查找{文件夹} -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也在这里证实: https://stackoverflow.com/a/17091831/538512

use the following format or a derivative thereof chmod -R u=rwX,go=rwX {folder}使用以下格式或其衍生物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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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