How to list all users in a Linux group?

后端 未结 20 1283
春和景丽
春和景丽 2020-12-07 06:51

How do I list all members of a group in Linux (and possibly other unices)?

20条回答
  •  感动是毒
    2020-12-07 07:47

    The following command will list all users belonging to , but only those managed by /etc/group database, not LDAP, NIS, etc. It also works for secondary groups only, it won't list users who have that group set as primary since the primary group is stored as GID (numeric group ID) in the file /etc/passwd.

    awk -F: '/^groupname/ {print $4;}' /etc/group
    

提交回复
热议问题