Linux 如何向组中的特定用户授予文件权限?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19337258/
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
How to give file permission to a specific user in a Group?
提问by Vijay
I have a Group 'g1' having 2 users Alice and Bob. I want to share a file 'file1' with both of them with different permissions.(for Alice read only and for Bob Read+write)
我有一个组“g1”,有 2 个用户 Alice 和 Bob。我想以不同的权限与他们共享一个文件“file1”。(对于 Alice 只读和对于 Bob 读+写)
采纳答案by MattSizzle
Assuming Bob can own the file the following should work for you.
假设 Bob 可以拥有该文件,以下内容应该适合您。
$ chown Bob:g1 file1
First set the ownership of the file to Bob to allow for read+write access and set the group ownership to the g1 group.
首先将文件的所有权设置为 Bob 以允许读+写访问,并将组所有权设置为 g1 组。
$ chmod 640 file1
Set the owner to a read and write and set the group to read only. This is a common permission structure on webservers. Note that the "world" has no permissions in this structure, but $ man chmod can provide further information on file permissions and get you where you are needing to go. Additionally if you need more control over your permissions across the whole system you may want to look into Posix ACLs or SE Linux as you did indicate you are on RedHat
将所有者设置为可读写,并将组设置为只读。这是网络服务器上常见的权限结构。请注意,“world”在此结构中没有权限,但 $ man chmod 可以提供有关文件权限的更多信息,并让您到达需要去的地方。此外,如果您需要对整个系统的权限进行更多控制,您可能需要查看 Posix ACL 或 SE Linux,因为您确实表明您使用的是 RedHat
回答by Rahul Tripathi
You may try like this in Linux:-
你可以在 Linux 中这样尝试:-
chown user_name file
chown user_name folder
chown -R user_name folder #recursive