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 |
Category | N/A |
Difficulty | Easy |
Root privileges | No |
Estimated completion time | 2m |
Purpose
Outputs members of a group.
Syntax
The basic syntax is as follows:
members groupNameHere
OR
members [options] groupNameHere
members command examples
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
Sample outputs:
$ members webmaster | wc -w
Sample outputs:
6
Display only primary group members
Pass the -p option:
$ members -p webmaster
Display only secondary group members
Pass the -s option:
$ members -s webmaster
Query /etc/group file
Use the following grep command:
grep '^webmaster' /etc/group
Use getent command to query groups
Use the following getent command to query group database (such as file or NIS based group database):
$ getent group | grep '^webmaster'
See also
- /etc/group file.
- members(1) Linux/Unix command man page
- Man pages – grep(1)
🐧 0 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |