Linux 更改组权限以匹配所有者权限
假设我在 Linux 上有一个目录,其中包含一堆文件和子目录。这就是根目录:
drwxr-xr-x 13 user1 group1 4096 May 7 15:58 apps
现在,我只想更改这些权限的组部分。我想对其进行更改,使其与所有者部分完全匹配。该目录的结果将是:
drwxrwxr-x 13 user1 group1 4096 May 7 15:58 apps
但是,我想要一个脚本或命令自动执行此操作,不仅针对该目录,而且针对该目录下递归的每个子目录和文件。有人知道怎么做吗?
谢谢。
Suppose I have a directory on Linux with a bunch of files and subdirectories. This is that root directory:
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试一下(首先测试一下):
当您指定字段(
u
、g
或o 时,
)在右侧,或者当您在右侧指定权限(=
会复制权限r
、w
或x
)时绝对设置它。Give this a try (test it first):
The
=
copies the permissions when you specify a field (u
,g
oro
) on the right side or sets it absolutely when you specify a permission (r
,w
orx
) on the right.这很简单:
That's simple: