≡ Menu

Linux: Find Out My Group Name [ Group Memberships ]

How do I find out the group name under Linux operating systems using bash shell prompt? How do I display group information for the specified USERNAME under Linux?

Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following command to list your group ownership i.e. display the groups a user is in:
$ users
Sample outputs:

vivek adm dialout cdrom plugdev lpadmin netdev admin sambashare libvirtd

vivek user is part of the above groups. To display group memberships for a user called tom, enter:
$ users userName
$ users tom

To print the primary group membership for a user called tom, enter:
$ id -g -n tom
To print the secondary group membership for a user called tom, enter:
$ id -G -n tom
You can also search /etc/group file as follows using the grep command:
$ grep Username /etc/group
$ grep vivek /etc/group

Sample outputs:

adm:x:4:vivek
dialout:x:20:vivek
cdrom:x:24:vivek
plugdev:x:46:vivek
lpadmin:x:105:vivek
netdev:x:112:vivek
admin:x:119:vivek
vivek:x:1000:
sambashare:x:122:vivek
libvirtd:x:125:vivek

See also:

If you need assistance with Linux groups membership related commands, turn to the man page first. It will give you detailed information, parameters and switches for the following commands:
$ man id
$ man groups
$ man 5 group

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:



{ 4 comments… add one }
  • mary poppins January 31, 2011, 9:46 am

    $ grep vivek /etc/group
    ->
    $ getent group vivek

    $ grep vivek /etc/passwd
    ->
    $ getent passwd vivek

  • john January 30, 2013, 4:38 pm

    According to the users man page, the users command prints the user names of users currently logged in to the current host. The “groups” command will print the groups a user is in.

  • Dan Dascalescu June 30, 2014, 8:48 pm

    This article is incorrect and needs to be updates. “users” will only display who’s logged in.

    Please make this correction because Cybercity is the top Google results for a lot of Linux-related searches.

  • sajsaj April 1, 2016, 2:41 pm

    cat /etc/group
    will list all group you have

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">


   Tagged with: , , , , , , , , , ,