0

If I command id nu, the output shows that the user nu belongs to the group named nuu. But if check the members of the group nuu with the command getent group nuu it shows as if there are no members in this group.

# id nu
uid=1002(nu) gid=1003(nuu) groups=1003(nuu)
# getent group nuu
nuu:x:1003:
# members nuu
nu

To reconfirm, I downloaded another utility named members and then using this command, I could again confirm the group nuu does have nu as its member. Why this discrepancy though?

Kulfy
  • 17,696

1 Answers1

2

A user doesn't need to be listed as the member of their primary group in the group database because that relationship is defined in the user's passwd entry. Generally, only supplementary group memberships are listed in the group database. Your outputs are consistent with this.

muru
  • 197,895
  • 55
  • 485
  • 740
  • I didn't fully understand, but got some idea. Your meaning is that this ubuntu command is designed this way and 'that command' won't show any group's primary members (but if the same group was someone's secondary group, then those members would've been returned/showed). If this is the case, can you pls tell if there is any other built-in/default ubuntu command, which would show all primary members of a group (command which is included in the ubuntu itself, i.e. we don't need to install any other packages for that command to work). Hope I was able to make myself clear. – Bathinda Helper Sep 01 '20 at 11:30
  • Unfortunately, no. You'll have to get all users, check their primary group, and then combine that with the memberships listed in getent group. – muru Sep 01 '20 at 12:05