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?
Asked
Active
Viewed 8,887 times
0
-
sorry, do you want all users in all groups, or all users in a particular group? – Zanna Jan 21 '18 at 19:54
-
https://www.cyberciti.biz/faq/linux-list-all-members-of-a-group/ – Panther Jan 21 '18 at 20:03
-
is this what you are looking for: `cat /etc/group` – ptetteh227 Jan 21 '18 at 20:26
2 Answers
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
- 90,425
- 20
- 200
- 267
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
Martin Loeffler
- 21
- 2