[Quick Tip] How 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 storage:x:95:sk
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
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:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!