Who are the members of a Linux group?
brian_s 270002K5X3 Visits (4464)
At first glance it might appear that you can just look at the /etc/group file, find the group in question, and see all of the users who are a member of the group from there. However, the /etc/passwd file is what records each users primary group membership, so if you only look in /etc/group you will miss everyone who has a primary group set to the group in question.
Here is one method that will return a list of all users of any given group for both users with the primary group set or as a secondary group:
Replace the “somegroup” with whichever group you need to look up membership for.
The command works by running the “id” command for every user on the system and grepping for the group you are looking for.