linux查看用戶所屬組有很多方法:
-
命令groups 查看當前用戶所屬組
[root@localhost xly]# groups
root
-
groups 用戶(查看用戶所屬組)
[root@localhost xly]# groups xly
xly : xly
-
id 用戶(查看用戶所屬組)
[root@localhost xly]# id xly
uid=500(xly) gid=500(xly) groups=500(xly)
-
直接查看組文件,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 /etc/group|grep 組名,用於查找某個用戶組
cat /etc/passwd |cut -f 1 -d :
在用戶狀態下,也可用groups來查詢。