Linux 如何在unix中一次为多个目录授予777权限?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19093613/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:57:50  来源:igfitidea点击:

How to give 777 permission to multiple directories at a time in unix?

linuxshellunix

提问by Dileep

I have several sub directories in a root directory. at a time i want to give chmod 777permission to those directories.

我在一个根目录中有几个子目录。有时我想chmod 777授予这些目录的权限。

i know individually we can give chmod -r 777 abcdbut i want to give permission to those directories which ever i require at a time.

我个人知道我们可以给予,chmod -r 777 abcd但我想给予我一次需要的那些目录的许可。

Example :

例子 :

XYZ -- Parent Directory 

ABCD EGF GHY JHF OIEDF -- These are sub directories.

now i want to give chmod 777 to ABCD EGF GHY . at a time to all these directories.

Thanks in Advance.

提前致谢。

回答by Geoffroy

Assuming XYZ is the path to the root of your files, you can use globbing to exactly match the files you want:

假设 XYZ 是文件根目录的路径,您可以使用通配符来精确匹配您想要的文件:

chmod 777 /XYZ/{ABCD,EGF,GHY}

Then you can use the -Rflag to do it recursively on all files and folders contained in these folders.

然后,您可以使用该-R标志对这些文件夹中包含的所有文件和文件夹递归执行此操作。

chmod -R 777 /XYZ/{ABCD,EGF,GHY}

To apply a non-recursive chmod on the 3 folder plus the parent, you can use:

要在 3 文件夹和父文件夹上应用非递归 chmod,您可以使用:

chmod 777 /XYZ/{ABCD,EGF,GHY,}

Note the last comma, to include the directory itself in the globbing

注意最后一个逗号,将目录本身包含在通配符中