0

I am still fairly new with Ubuntu and I forgot the command to show all the users of a group. How do you show all the users in all thee groups?

2 Answers2

6

getent (comes with libc-bin) is what you're looking for.

And you want to parse the group database (/etc/group and/or alike) e.g.:

getent group adm

will get you the relevant entry for group adm, including the group membership info.

The fields are:

<group_name>:<group_password>:<group_id>:<members>

If you just want the usernames of the members:

getent group adm | awk -F: '{print $NF}'

The added advantage of getent is that it would fetch the data from network too, if configured on /etc/nsswitch.conf.

On my system:

% getent group adm
adm:x:4:syslog,foobar

% getent group adm | awk -F: '{print $NF}'
syslog,foobar
heemayl
  • 91,753
0

I'm also quite new. Thats the way I am doing it: Change to the /etc folder

cd /etc

then open the file group with an editor of your choice (e.g. nano)

nano group

here you will see a list of all groups followed by the group members