Check the groups to which a user belongs
Check the group in /etc/passwd and /etc/group (check the gid)
Users always belong to a group, and the group described in the /etc/passwd and /etc/group files is the primary group.
The gid (group ID) is stored in the /etc/passwd and /etc/group files
$ grep sampleuser /etc/passwd sampleuser:x:1002:1003::/home/sampleuser:/bin/bash $ grep sampleuser /etc/group sampleuser:x:1003: |
●Check the group with the id command
The id command specifies the user name as an argument.
The uid displays the user group, the gid displays the primary group, and the affiliation group displays all the groups to which the user belongs.
$ id sampleuser uid=1002(sampleuser) gid=1003(sampleuser) groups=1003(sampleuser) |
●Check groups with the groups command
The groups command also requires a user name as an argument
$ groups sampleuser sampleuser : sampleuser |
●Display the group list with the getent command
$ getent group root:x:0: bin:x:1: daemon:x:2: sys:x:3: adm:x:4: tty:x:5: ~中略~ systemd-network:x:192:rpc:x:32: mysql:x:1009: centos7:x:1010: |