bash Linux 更改组权限以匹配所有者权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3727866/
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
Linux change group permission to match owner permissions
提问by Dave L.
Suppose I have a directory on Linux with a bunch of files and subdirectories. This is that root directory:
假设我在 Linux 上有一个包含一堆文件和子目录的目录。这是根目录:
drwxr-xr-x 13 user1 group1 4096 May 7 15:58 apps
Now, I only want to alter the group portion of those permissions. I want to alter it in such a way that it exactly matches the owner portion. The result for that directory would be:
现在,我只想更改这些权限的组部分。我想对其进行更改,使其与所有者部分完全匹配。该目录的结果将是:
drwxrwxr-x 13 user1 group1 4096 May 7 15:58 apps
But, I want a script or command to do this automatically, not just for that directory but for every subdirectory and file recursively under it. Anyone know how?
但是,我想要一个脚本或命令自动执行此操作,不仅针对该目录,而且针对其下递归的每个子目录和文件。有谁知道怎么做?
Thanks.
谢谢。
回答by Paused until further notice.
Give this a try (test it first):
试试这个(先测试一下):
chmod -R g=u apps
The =copies the permissions when you specify a field (u, gor o) on the right side or sets it absolutely when you specify a permission (r, wor x) on the right.
该=副本时,你指定一个字段(权限u,g或o右侧)或将完全在您指定的权限(r,w或x右侧)。
回答by lazyfrosch
That's simple:
这很简单:
chmod g=u <file>

