Linux id command

Linux 命令大全Linux Commands Encyclopedia

The Linux id command is used to display the user's ID and the ID of the group to which they belong.

id displays the real and effective IDs of the user and their group. If the two IDs are the same, only the real ID is shown. If only a username is specified, it displays the current user's ID.

This command displays the user's UID (User ID), GID (Group ID), and all group IDs the user belongs to.

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 names of the user, their group, or supplementary groups.
  • -r or --real: Display the real ID.
  • -u or --user: Display the user ID.
  • -help: Display help.
  • -version: Display version information.

Examples

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 the 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 命令大全Linux Commands Encyclopedia

Other Extensions