Using the Linux 'id' Command

Use 'id' to display basic user and group info within a shell session

The Linux command id displays basic information about the current or a specific user account, including the account's primary and secondary user groups.

The id command is built into most Linux distributions. It's accessed through a shell session.

For system information, rather than user information, run the uname command, instead.

linux id command

About the id Command

Linux supports several methods of identifying user accounts from a shell session. A common version—id—displays basic information about the logged-in user. This command accepts several flags and arguments, including account names. Thus, user bob running id see his information, but id fred displays information about the fred account.

The command accepts the following format:

id [option] [user]

The user argument is the name of any valid user account. The options for this command include:

  • -Z: displays only the security context of the process
  • -g: prints the primary (effective) group ID
  • -G: prints all associated group IDs
  • -n: prints the group name(s) instead of the numbers, for use with the -ugG flags only
  • -r: prints the real ID instead of effective ID, for use with -ugG
  • -U: prints only the effective user ID
  • -z: uses null characters instead of whitespace to delimit entries

Without any arguments or options, id returns a full-group summary for the current user.

Some people use su to substitute to a different user account. To check which account is valid, instead of using id, use whoami.