Home » Linux » Basic Linux Commands » How to check Groups of User in Linux ?

How to check Groups of User in Linux ?

In Linux, which is a multi user operating system, we can group few number of users from all users and create a group of those users to assign certain permissions.

By default, when you create a new user in Linux, it also creates a group with same name. i.e. the user is in group of itself when it is created, but you can change the group of the user from one group to another.

In this post, we will see how you can check the group membership of the user.

$ groups

devlab adm cdrom sudo dip plugdev lpadmin sambashare

As, we can see there are multiple groups available in the system, and our user “devlab” is part of those many groups.

The groups command in Linux displays the groups a user is a member of. The syntax is as follows:

groups [OPTION]... [USERNAME]

Where OPTION can be -n (display numeric group IDs) or -p (display a list of groups separated by colons), and USERNAME is the name of the user whose groups you want to display. If no username is specified, the groups of the current user will be displayed.

We can also check the same using “id” command as,

$ id

uid=1000(devlab) gid=1000(devlab) groups=1000(devlab),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),116(lpadmin),126(sambashare)

Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment