简体   繁体   English

如何管理Linux文件夹的权限?

[英]How to manage permissions on Linux folders?

I'm a little bit confused with Linux permissions. 我对Linux权限有点困惑。 I'm configuring a Git Central Repository that the users access by SSH. 我正在配置用户通过SSH访问的Git Central Repository。 I'm using Filesystem ACLs( link ) and regular linux permissions. 我正在使用文件系统ACL( 链接 )和常规Linux权限。 What I intend to do is: 我打算做的是:

  • Find a way in that only the users that I want will be able to list/read/write/execute the dir "/var/github" (in a way that I assign a group to the user that I want to give this kind of permissions) 找到一种方法,只有我想要的用户才能列出/读/写/执行dir“/ var / github”(以我为用户分配组的方式,我想给这种类型的权限)
  • The user "git" is the only user that can create new folders in "/var/github" 用户“git”是唯一可以在“/ var / github”中创建新文件夹的用户

This is possible to do? 这有可能吗? Somes clues on how to do it? 有些人提供了如何做到这一点的线索?

Best Regards, 最好的祝福,

chown git:git /var/github; chmod 750 !$

现在只有组git可以读取文件夹,只有用户git可以修改它。

Make sure that along with the user "git" that there is a "git" group. 确保与用户“git”一起存在“git”组。 Add all the users to the group that you will give access to. 将所有用户添加到您将授予访问权限的组中。 Change the ownership properties of your directory to user and group git, and then the permission of 750. The ownership and mode commands are as follows: 将目录的所有权属性更改为用户和组git,然后将权限更改为750.所有权和模式命令如下:

chown git:git /var/github
chmod 750 /var/github

The permission of 750 lets the user do pretty much anything in the folder and only the members of the group "git" read and possibly execute in that folder. 750的权限允许用户在文件夹中执行几乎任何操作,只有组“git”的成员读取并可能在该文件夹中执行。 What programs and commands you use for your user management is up to you. 您用户管理所使用的程序和命令取决于您。

You can use access control lists to grant access to multiple groups. 您可以使用访问控制列表授予对多个组的访问权限。 Here's an example session (using Ubuntu, but it should be the same for CentOS) that gives the grp1 group read access and the grp2 group read, write and execute access: 这是一个示例会话(使用Ubuntu,但它应该与CentOS相同),它为grp1组提供读访问权限,并为grp2组提供读,写和执行访问权限:

$ touch foo
$ setfacl -m "g:grp1:r--,g:grp2:rwx" foo
$ getfacl foo
# file: foo
# owner: me
# group: me
user::rw-
group::r--
group:grp2:rwx
group:grp1:r--
mask::rwx
other::r--

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM