id
—
return user identity
The id
utility displays the user and group names and
numeric IDs, of the calling process, to the standard output. If the real and
effective IDs are different, both are displayed, otherwise only the real ID is
displayed.
If a user (login name or user ID) is
specified, the user and group IDs of that user are displayed. In this case,
the real and effective IDs are assumed to be the same.
The options are as follows:
-A
- Display the process audit user ID and other process audit properties,
which requires privilege.
-G
- Display the different group IDs (effective, real and supplementary) as
white-space separated numbers, in no particular order.
-M
- Display the MAC label of the current process.
-P
- Display the id as a password file entry.
-a
- Ignored for compatibility with other
id
implementations.
-c
- Display current login class.
-g
- Display the effective group ID as a number.
-n
- Display the name of the user or group ID for the
-G
, -g
and
-u
options instead of the number. If any of the ID
numbers cannot be mapped into names, the number will be displayed as
usual.
-p
- Make the output human-readable. If the user name returned by
getlogin(2) is different from the login name referenced by
the user ID, the name returned by
getlogin(2) is displayed, preceded by the keyword
“login”. The user ID as a name is displayed, preceded by the
keyword “uid”. If the effective user ID is different from
the real user ID, the real user ID is displayed as a name, preceded by the
keyword “euid”. If the effective group ID is different from
the real group ID, the real group ID 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 ID for the
-g
and
-u
options instead of the effective ID.
-u
- Display the effective user ID as a number.
The id
utility exits 0 on success,
and >0 if an error occurs.
The id
function is expected to conform to
IEEE Std 1003.2 (“POSIX.2”).
The historic
groups(1) command is equivalent to “id
-Gn
[user]”.
The historic
whoami(1) command is equivalent to “id
-un
”.
The id
command appeared in
4.4BSD.