Linux/Unix:How To Check User Belong To Which Groups
For a new linux Admin, How to check a user belong to which groups in linux server, or a user is in which group membership, this post will show you that using groups command to print the groups a user is in .
Check The Groups Membership Of A User
If you want to get the user’s groups membership, the syntax is as followss:
groups <username>
Example:
print the groups of “atest” user is in, just issue the follwoing command in the command line interface;
groups atest
OutPut:
[root@localhost ~]# groups atest atest : btest ctest dtest
If you want to check the user ‘s detailed infomation, using “id” command passing “username”, will output user’s uid, gid, groups information.
[root@localhost ~]# id atest uid=503(atest) gid=504(btest) groups=504(btest),505(ctest),506(dtest) context=root:system_r:unconfined_t:SystemLow-SystemHigh
You can grep /etc/passwd or /etc/group files to get more user or group’s information, those two files store all user and groups membership.
Done…..