Linux: members Command Examples

by on January 29, 2013 · 0 comments· LAST UPDATED January 29, 2014

in , , ,

members command

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.

members command details
DescriptionShow members of a group
Category
Difficulty
Root privilegesNo
Estimated completion time2m
Contents

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:

Animated gif 01: Displaying a list of members of a group called webmaster

Animated gif 01: Displaying a list of members of a group called 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
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
CategoryList of Unix and Linux commands
File Managementcat
Network Utilitiesdighostip
Processes Managementbgchrootdisownfgjobskillkillallpwdxtimepidofpstree
Searchingwhereiswhich
User Informationgroupsidlastlastcommlognameuserswwhowhoamilidmembers

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 0 comments… add one now }

Leave a Comment

Tagged as: , ,

Previous Faq:

Next Faq: