I am a new Linux and Unix system user. How do I list the members of a group on Linux or Unix-like systems?
There are various ways to get this information on both Linux and Unix-like system.[donotprint]
|members command details|
|Description||Show members of a group|
|Estimated completion time||2m|
Outputs members of a group.
The basic syntax is as follows:
members [options] groupNameHere
Buy default members command display all group members on one line. Open the Terminal application and type the following command to display members of ‘webmaster’ group:
$ members webmaster
In this example, six users are output: webadmin, raj, vivek, archana, sai, and sayali. You can count total users in a group called members using wc command:
$ members webmaster | wc -w
Pass the -p option:
$ members -p webmaster
Pass the -s option:
$ members -s webmaster
Use the following grep command:
grep '^webmaster' /etc/group
Use the following getent command to query group database (such as file or NIS based group database):
$ getent group | grep '^webmaster'
- /etc/group file.
- members(1) Linux/Unix command man page
- Man pages – grep(1)