Home >Operation and Maintenance >Linux Operation and Maintenance >How to check which group a user belongs to in Linux
There are many ways to view the groups to which a user belongs in Linux:
Command groups to view the groups to which the current user belongs
[root@localhost xly]# groups root
groups users (view the groups to which the user belongs)
[root@localhost xly]# groups xly xly : xly
Recommended tutorial: linux tutorial
id user (view the group to which the user belongs)
[root@localhost xly]# id xly uid=500(xly) gid=500(xly) groups=500(xly)
View the group file directly, cat /etc/group
[root@localhost xly]# 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:
cat group name, used to find a user group
cat /etc/group|grep
Related video tutorial 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!