I've recently been creating new users and assigning them to certain groups. I was wondering if there is a command that shows all the users assigned to a certain group? I have tried using the 'groups' command however whenever I use this it says 'groups: not found'

Best Answer


I prefer to use the getent command ...

Since getent uses the same name service as the system, getent will show all information, including that gained from network information sources such as LDAP.

So for a group, you should use the following ...

getent group name_of_group

where name_of_group is replaced with the group you want to look up. Note that this only returns supplementary group memberships and does not include users who have this group as their primary group

There are a whole lot of other lookups that you can do ... passwd being another useful one, which you'll need to list primary groups.