How to find the user or myself belongs to which group? Because group is important for the folder and device access permissions. One user can be join multiple or single group. We can get our current group membership or another user group membership.
Who Am I?
First when we log in a system we may want to get our username and user account related information. We will use whoami
command.
$whoami

Print User Group Names
I can get my group membership by using groups command without providing any parameter. We will use groups
command to print current user group name.
$groups

- As we expected root user is in the root group
Another User Group Membership
I want to get other user group membership. There is no need for parameter. We will use groups
command and provide the user we want to print.
$ groups root

- groups will give group membership information of test2
- test2 is the user we want to get group membership
- mysql and root are group names of the test2 joined