[Quick Tip] How To Find Out Which Groups A User Belongs To

Find Out Which Groups A User Belongs To

The other day I was installing Dropbox on Ubuntu 18.04 LTS server edition. When configuring Dropbox, I had a situation where I needed to enter my current user name and the group name. Of course, I know (and any experienced users) how to easily find out which groups a user belongs to, but not the newbies. So, I thought it would be helpful for the newbies if I post the procedures in our blog, hence this tutorial. Now let us go ahead and find out which groups a user belongs to in Unix-like operating systems.

Find Out Which Groups A User Belongs To

In Unix-like operating systems, the groups command displays the current group names and the users belongs to those groups.

First, let us take a look at how many are there in a Linux system. Entering the groups command without any argument will display the available groups.

$ groups
wheel network audio optical storage power users vboxusers

As you can see, I do have 8 groups in my system. No let us find out which groups my user belongs to. To do so, enter:

$ groups sk
wheel network audio optical storage power vboxusers users

Here, sk is my username and the user sk is the member of all of the above groups.

We can also find the list of users that belongs to a specific group. For instance, the following command displays the users which are belongs to the group named storage.

$ grep -w storage /etc/group

Easy, right? Indeed. Finding which groups a user belongs and the users of a specific group is super easy!! For more details about groups command, refer man pages.

$ man groups

Also read:

And, that’s all for now. Hopes this helps. If you find this guide useful, please spend a moment to share it on your social, professional networks and support OSTechNix.

More good stuffs to come. Stay tuned!


Thanks for stopping by!

Help us to help you:

Have a Good day!!

You may also like...

1 Response

  1. tak says:

    What about ID?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.