Rootop 服务器运维与web架构

关于Linux下 属主、属组、其它 的权限问题

| 暂无评论

        建立A用户 隶属a,b组 ;B用户隶属b,c组,在A用户内建立文件“1”权限设置为chmod 707 1, 然后以B用户的身份打开文件可以打开但将1的权限设置为770后 B用户则无法访问或修改.

        这是在百度里某兄台提出的问题,我一看,眨眼也迷糊了,一想是这么回事:

useradd a
useradd b
usreadd c

[root@dot5 ~]# groups a
a : a
[root@dot5 ~]# groups b
b : b
[root@dot5 ~]# groups c
c : c
[root@dot5 ~]# usermod -G b a
[root@dot5 ~]# groups a
a : a b
[root@dot5 ~]# usermod -G c b
[root@dot5 ~]# groups b
b : b c

[a@dot5 tmp]$ touch 1
[a@dot5 tmp]$ chmod 707 1
[a@dot5 tmp]$ ls -ld 1
-rwx—rwx 1 a a 32 12-24 18:26 1
[a@dot5 tmp]$
看,第一个a是属主,第二个a是所属组,b用户是bc组,a用户是ab组,可见b用户不属于a组,1的组权限为0,就是只针对a组的,所以b不受影响。

补充:

groups $username   //查看用户所属组

usermod -g              //修改主组     只能有一个主组

usermod -G            //附属组   可以拥有多个附属组

原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/197.html

作者:Venus

服务器运维与性能优化

发表回复