"getent" doesn't show members in the group

"getent" doesn't show members in the group

如果我命令id nu,输出显示用户nu属于名为 的组。但如果使用 命令nuu检查该组的成员,则显示该组中没有成员。nuugetent group nuu

# 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?

答案1

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.

相关内容