Linux id Command
The Linux id command displays a user's ID and the IDs of the groups they belong to.
id shows the real and effective IDs of a user and their groups. If the two IDs are the same, only the real ID is shown. If only a username is given, the ID of the current user is shown.
This command displays the user's UID (User ID), GID (Group ID), and all group IDs the user is a member of.
Syntax
id [-gGnru][--help][--version][用户名称]
Parameter Description:
- -g or --group Display the ID of the group the user belongs to.
- -G or --groups Display the IDs of the supplementary groups the user belongs to.
- -n or --name Display the name of the user, group, or supplementary group.
- -r or --real Display the real ID.
- -u or --user Display the user ID.
- -help Display help.
- -version Display version information.
Example
Display current user information:
# id //显示当前用户ID
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=root:system_r:unconfined_t
Display a user's group ID:
# id -g
0
Display all group IDs:
# id -G
0 1 2 3 4 5 6 10
Display information for a specified user
# id hnlinux
Linux Command Reference