Home>Article>Operation and Maintenance> How to check which group a user belongs to in Linux
View method: 1. Directly execute the "groups" command to view the groups to which the current user belongs; 2. Execute the "groups username" command to view the groups to which the specified user belongs; 3. Execute "id username" command to view the groups to which the specified user belongs; 4. Execute the "cat /etc/group" command to output the group file information.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
Linux method to check which group a user belongs to:
Method 1: Usegroups
directly to view The group to which the current user belongs
# groups root
Method 2: Usegroups username
to view the group to which the specified user belongs
# groups xly xly : xly
Method 3: Useid username
to view the group to which the specified user belongs
# id xly uid=500(xly) gid=500(xly) groups=500(xly)
Method 4: Directly view the group file,cat /etc/group
# cat /etc/group root:x:0: bin:x:1:bin,daemon daemon:x:2:bin,daemon sys:x:3:bin,adm adm:x:4:adm,daemon tty:x:5: disk:x:6: lp:x:7:daemon mem:x:8: kmem:x:9: xly:x:500:
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of How to check which group a user belongs to in Linux. For more information, please follow other related articles on the PHP Chinese website!