如何设置目录具有持久组权限?
我们有两个用户:
- user1
- user2
他们都属于“admin”组。
我们有一个目录已设置为 775。该目录的组已更改为“admin”。 每个用户都具有写入该目录的完全访问权限,但当用户将新文件写入该目录时,该文件夹的组权限不会保留到写入的文件中。
应该如何让文件继承目录的组权限呢?
澄清:当写入新文件或目录时,它使用用户组作为新文件的组,而不是目录的组,这是有道理的 - 但我如何才能不发生这种情况呢?
We have two users:
- user1
- user2
They both belong to the group 'admin'.
We have a directory that has been set to 775. The directory's group has been changed to 'admin'. Each user has full access to write into that directory, though when a user writes a new file to the directory, the group permissions of the folder are not persisted to the file that was written.
How should we make it so that files inherit the directory's group permissions?
Clarification: when a new file or directory is written, it uses the users' group as the group of the new file, rather than that of the directory, which makes sense - but how do I not make that happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过设置目录的 setgid 位 (
chmod g+s
) 来传播组权限。这可能无法在所有 *nix 和所有文件系统之间移植。http: //en.wikipedia.org/wiki/Setuid#setgid_on_directories
http://www.gnu.org/software/coreutils/manual/html_node/Directory-Setuid-and-Setgid.html
You can propagate group permissions by setting the directory's setgid bit (
chmod g+s
).This may not be portable across all *nixes and all file systems.http://en.wikipedia.org/wiki/Setuid#setgid_on_directories
http://www.gnu.org/software/coreutils/manual/html_node/Directory-Setuid-and-Setgid.html
如果您使用的是 ext3 或 ReiserFS,请参阅此有关创建 Linux 文件服务器的页面 可能会有所帮助。 具体来说,步骤 7 建议使用以下命令。
If you are using ext3 or ReiserFS, this page about creating a Linux file server may help. Specifically step 7 suggests the following command.
我认为你应该看看这里。
正如该网站所说,“Unix 不支持继承权限的想法。”
但是,有一个关于 ACL(访问控制列表)的部分,我认为这就是您正在寻找的内容。 通过设置 ACL,您可以让文件从目录继承相同的 ACL,我认为这就是您所要求的。 setfacl 是您需要研究的 shell 命令。
希望有帮助!
I think you should look here.
As the site says, "Unix doesn't support the idea of inherited permissions."
However, there is a section on ACLs (Access Control Lists), which I think is what you are looking for. By setting up an ACL, you can have your files inherit the same ACL from the directory, which I think is what you are asking for. setfacl is the shell command that will be what you need to look into.
Hope that helps!