1

If I am not wrong, the file /etc/group shows the list of the groups and for each one are listed the users that are members as secondary group only. I created some users in order to do some test. The strange behavior is that my user is listed in my primary group. The other users don't appear in them primary groups. Do you have any idea? Here you are the example on my CentOS system:

[root@server2 ~]# id intore
uid=1000(intore) gid=1000(intore) groups=1000(intore),10(wheel)

root@server2 ~]# cat /etc/group
lisa:x:1001:
lisa_m:x:1002:
betty:x:1009:
sales:x:1007:bob,betty,linda,lisa
account:x:1008:bill,beatrix,lori,bob
bill:x:1010:
beatrix:x:1011:
linda:x:1003:
wheel:x:10:intore,lisa,lisa_m
intore:x:1000:intore
Hauke Laging
  • 90,279
intore
  • 399
  • 2
    What system is this on and how did you create the users? – Kusalananda Jan 20 '18 at 13:10
  • This looks like a very wrong group file. I hope that output from can is trimmed. – fugitive Jan 20 '18 at 13:38
  • @Kusalananda: the system is CentOS 7, the user "intore" is the first user created during the installation process. The other users have been added by using useradd command – intore Jan 20 '18 at 14:28
  • @fugitive: sure, that output is a part of the group file – intore Jan 20 '18 at 14:29
  • Note that it doesn't make any practical difference. A user is in the group specified as their primary group in /etc/passwd (or, more generally, getent passwd), AND in any groups that list them in /etc/group (getent group). They may, or may not, be listed explicitly in their primary group's entry but it makes no difference to their group membership status either way. – cas Jan 21 '18 at 05:11
  • @cas, yes I know there is no difference about the belonging of a user to his primary group. It was just for a clarification. thanks – intore Jan 21 '18 at 10:44

1 Answers1

2

If you add a user to a group by making the group its primary one then the user is not added to the user list in /etc/groups.

Some distros create a group for each user. It makes some sense to add the user to that group in the group file so that the user is a member even if the primary group is changed.

Of course, you could make that argument for other groups, too.

Hauke Laging
  • 90,279