How can I see all the members of a group in Linux?
Asked
Active
Viewed 3.3e+01k times
3 Answers
32
You can do
members YOUR_GROUP_NAME
and it will list all the users in the group YOUR_GROUP_NAME
.
If it's not installed by default:
sudo apt-get install members
-
1
-
10
-
-
3it was not installed by default in 20.04 Desktop LTS, even after a successful smb and cif-utils installation – Marcelo Scofano Diniz Jan 03 '21 at 17:03
20
One more way to check all the members of a group is by checking the /etc/group
file which lists all the groups and its members
Example:
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:syslog,nikhil
tty:x:5:
disk:x:6:
lp:x:7:
mail:x:8:
news:x:9:
uucp:x:10:
man:x:12:
proxy:x:13:
kmem:x:15:
dialout:x:20:
fax:x:21:
voice:x:22:
cdrom:x:24:nikhil
floppy:x:25:
tape:x:26:
sudo:x:27:nikhil
audio:x:29:pulse
The first string (separated by :) specifies the group name and the last string specifies the user added to this group.

Nikhil Katre
- 301
- 2
- 3
members <group>
probably gives more what the OP is looking for. The difference is explained here Link – RichEarle Aug 19 '22 at 15:04groups root && getent group root
andgroups lxd && getent group users
. Can anybody shed some light why in above cases root user is not listed as a member of a root group as well as lxd user (you need to have LXD/LXC installed) is not listed as a member of a users group where in fact both have groups assigned to them in groups? Howevergroups pulse && getent group audio
works as expected and pulse user listed as a member of an audio group in both command outputs. – igor Sep 17 '23 at 14:15getent group groupname
withcompgen -u | xargs -I {} sh -c 'groups {}'
for the following groups: audio, lp, nogroup, plugdev, users on Ubuntu 22 LTS. Is there an explanation for such behaviour? – igor Sep 17 '23 at 14:37