Linux/Unix: List All Users In A Group Command

by on January 29, 2014 · 1 comment· LAST UPDATED January 29, 2014

Fig. 01: members command in action to list members in a group

To see user's groups or group's users use any one of the following command:

 
grep '^groupNameHere' /etc/group
lid -g groupNameHere
members groupNameHere
awk -F':' '/^groupNameHere/{print $4}' /etc/group
getent group | grep -i  'groupNameHere'
 

In this example find all users in a group called cartoon.

grep command example

grep '^cartoon' /etc/group
Sample outputs:

cartoon:x:1009:tom,jerry,spike,tyke,butch,nibbles,quacker

lid command example

lid -g cartoon
Sample outputs:

 tom(uid=1007)
 jerry(uid=1008)
 spike(uid=1009)
 tyke(uid=1010)
 butch(uid=1011)
 nibbles(uid=1012)
 quacker(uid=1013)

members command example

members cartoon
Sample outputs:

tom jerry spike tyke butch nibbles quacker

awk command example

awk -F':' '/^cartoon/{print $4}' /etc/group
Sample outputs:

tom,jerry,spike,tyke,butch,nibbles,quacker

getent command example

This example with NIS and other database too:
getent group | grep -i '^cartoon'
Sample outputs:

cartoon:x:1009:tom,jerry,spike,tyke,butch,nibbles,quacker
See also
TwitterFacebookGoogle+Found an error/typo on this page? Help us!

Examples and usage: Linux: Show All Members of a Group

{ 1 comment… read it below or add one }

1 Or June 28, 2014 at 12:21 am

In “cartoon:x:1009:”
what doas ‘x’ means?
what doas ‘1009’ means?

Reply

Leave a Comment

Tagged as: