Which Groups Belong To A User In Linux – POFTUT

Which Groups Belong To A User In Linux


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
Who Am I?
Who Am I?

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
My Group Memberships
My Group Memberships
  • 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
Another User Group Membership
Another User Group Membership
  • 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

 

Which Groups Belong To A User In Linux Infografic

LEARN MORE  How To Change or Rename Username and User ID In Linux?

Leave a Comment