Linux 组配置文件(/etc/group),etcgroup


一、概述

Linux 组配置(/etc/group)文件分为4个字段,分别为:

组名、组密码、GID和组成员。

 

二、示例

[root@titan ~]# cat /etc/group | grep fruit

fruit:x:1001:

其中,fruit为组名,x为组密码,1001为GID,组成员字段为空。

用户apple和banana的默认组为fruit。

[root@titan ~]# id apple

uid=1001(apple) gid=1001(fruit) 组=1001(fruit)

[root@titan ~]# id banana

uid=1002(banana) gid=1001(fruit) 组=1001(fruit)

组成员字段为空时存在2种情况:(1)该组不包含用户;(2)该组包含用户,但上述用户以该组为默认组。

[root@titan ~]# cat /etc/group | grep fruit

fruit:x:1001:

 

三、问题

问题:某用户显示在组成员字段时,该组是否一定不是此用户的默认组?

答案:否。

 

用户apple显示在组trick的组成员字段,组trick是用户apple的默认组。

[root@titan ~]# cat /etc/group | grep trick

trick:x:1002:apple

[root@titan ~]# id apple

uid=1001(apple) gid=1002(trick) 组=1002(trick)

 

原因分析

创建用户apple时使其默认组为组fruit,并将其添加至组trick,随后将用户apple默认组修改为组trick。

 

相关内容