id - Return user identity

Synopsis

id [user]

id -G [-n] [user]

id -g [-nr] [user]

id -p [user]

id -u [-nr] [user]

Description

The id utility displays the user and group names and numeric identifiers, of the calling process, to standard output. If the real and effective identifiers are different, both are displayed, otherwise only the real identifier is displayed.

If a user (login name or user identifier) is specified, the user and group identifiers of that user are displayed. In this case, the real and effective identifiers are assumed to be the same.

Options

-G
Display the different group identifiers (effective, real and supplementary) as white-space separated numbers, in no particular order.
-g
Display the effective group identifier as a number.
-n
Display the name of the user or group identifier for the -G, -g and -u options instead of the number. If any of the identifier numbers cannot be mapped into names, the number will be displayed as usual.
-p
Make the output human-readable. The user identifier as a name is displayed, preceded by the keyword "uid". If the effective user identifier is different from the real user identifier, the real user identifier is displayed as a name, preceded by the keyword "euid". If the effective group identifier is different from the real group identifier, the real group identifier is displayed as a name, preceded by the keyword "rgid". The list of groups to which the user belongs is then displayed as names, preceded by the keyword "groups". Each display is on a separate line.
-r
Display the real identifier for the -g and -u options instead of the effective identifier.
-u
Display the effective user identifier as a number.

Exit status

  • 0 on success
  • >0 if an error occurs.
Examples
Display all user and groups identifiers that belong to the user "SAM".
id -p SAM
uid      SAM
groups     500, 1