6

Consider this situation.

A user called _example is created without assigning him to any group.

A new group is manually added to /etc/group called _example without any users.

Is the _example user automatically part of _example group now or does he still need to be explicitly added to the group?

Michal M
  • 319
  • 1
  • 5
  • 15

2 Answers2

5

No. Unless the user's group is set to _example (in the password file) or the user is explicitly added to the _example group in /etc/group, the user is not a member of that group.

Matt Simmons
  • 20,396
  • 10
  • 68
  • 116
  • Does it mean that if I do `cat /etc/group` I may not necessarily see all users in a group? I thought that was the case, but it seems not. E.g. in `/etc/group` I have a group called `apache`, with GID 48, which is listed as including user `osullic` (and no other user). But in `/etc/passwd` I have a user `apache` whose GID is listed there as 48. So in fact, `apache` group includes 2 users (`osullic` and `apache`), even though only 1 is listed in `/etc/group`? – osullic Feb 10 '21 at 12:15
3

Users must be explicitly added to any group. It is common convention to have a group for named the same as each user. The operable theory is that other users may be added to a particular user's group in an adhoc fashion allowing the user to control which files are exposed to that group.

Jeff Ferland
  • 20,547
  • 2
  • 62
  • 85