Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

id - return user identity

&pagelevel(4)&pagelevel

id writes the following on the standard output for the invoking process:

  • the user ID (UID)

  • the login name

  • the group ID (GID)

  • the group name.

If the effective and real IDs/names are not identical, both are printed.


Syntax


Format 1:id[ -a][ user]
Format 2:id -G[ -n][ user]
Format 3:id -g[ -nr][ user]
Format 4:id -u[ -nr][ user]



Format 1:id[ -a][ user]


-a

(all)

In addition to the ID and login name of the user, id reports all the groups to which the invoking process belongs and all the groups to which the invoking user belongs.

user

Login name for which the information is output.
If user is specified and the process possesses the relevant access permission then the user ID and group ID of the selected user are output. In this case it is assumed that the effective and real IDs are identical. If the database lists more than one permitted group assignment for the user then these assignments are also output.

user not specified
If the user operand is not specified then id outputs the user and group IDs together with the corresponding login name and group name of the caling process at the standard output.


Format 2:id -G[ -n][ user]


-G

Only the various group IDs (effective, real and supplementary) are output in the format "%u\n". If more than one group assignment is present then all group assignments are output in the format "%u" before the newline character.

-n

Outputs the name in the format "%s" instead of the format "%u".

user

see format 1


Format 3:id -g[ -nr][ user]


-g

Only the effective group ID is output.

-n

Outputs the name as a string.

-r

Only the real ID is output.

user

see format 1


Format 4:id -u[ -nr][ user]


-u

Only the effective user ID is output.

-n

Outputs the name as a string.

-r

Only the real ID is output.

user

see format 1

File

/etc/group

Group file containing group names and the associated group IDs and login names.

Locale

The following environment variables affect the execution of id:

LANG

Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined.

LC_ALL

If set to a non-empty string value, override the values of all the other internationalization variables.

LC_CTYPE

Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other.

LC_MESSAGES

Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.

NLSPATH

Determine the location of message catalogs for the processing of LC_MESSAGES.

Example

To check your current user ID, group ID, and their corresponding names, you enter:

$ id

id might then report the following:

uid=227(USER1) gid=100(USROTHER) groups=100(USROTHER)

See also

logname, newgrp, who,
getuid() [4]