Jump to content



How to display users in groups

  • Please log in to reply
No replies to this topic

#1 brent



  • Administrators
  • 11 posts

Posted 16 February 2013 - 06:32 AM

It isn't obvious at first how to list all the member of a group from a linux command line (I'm using Ubuntu Server 12.04 LTS)


Listing a user's Groups


It is very easy to list the groups that a user belongs to. Simply use the groups command.


groups username


This command will output the user name and a space-delimited list of all the groups that user belongs to, as follows.

user : user dialout cdrom floppy audio dip vido plugdev users fuse lp admin sambashare


Listing a Group's members (Users)

If you want to do the opposite, and list the members of a group, you can use the members command. The catch is: the command is not installed by default. Fortunately, it is simple to install:


sudo apt-get install members


Once the package is installed, you can issue the members command similarly to how you issue the groups command.


members groupname

This will output a space-delimited list of all the members of the group, as follows:


                              member1 member2 member3

Unlike the groups command, it does not output the name of the group. You may use the optional arguments --primary and --secondary to list only the primary or secondary users within the grooup.


alternatively if you want a quick look here are the commands.

cat /etc/passwd
cat /etc/group

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users