id

NAME

id - return user identity

SYNOPSIS

id [-D] [user]
id [-D] -G [-n] [user]
id [-D] -g [-nr] [user]
id [-D] -p [user]
id [-D] -u [-nr] [user]

DESCRIPTION

The id(1) utility displays the user and group names and numeric identifiers (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 you specify a user (by logon name or user ID), id(1) displays the user and group IDs of that user. In this case, the real and effective IDs are assumed to be the same.

OPTIONS

-D
Prefixes the name of the domain to user and group names. Without this option, the domain is prefixed to the name only if the user or group does not belong to the principal domain of the system.
-G
Display the different group IDs (effective, real and supplementary) as white-space separated numbers, in no particular order.
-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. Names are displayed in the following format:
name The user or group belongs to the system's principal domain.
+name The user or group is a built-in (well-known) user or group, such as Everyone.
domain+name The user or group belongs to a domain other than the principal domain.
-p
Print output in a "pretty" format which consists of up to five lines:
login  login_name
uid	real_user_name
euid   effective_user_name
rgid   real_group_name
groups group_list

If login_name is the same as real_user_name then the login line is not printed. If the real and effective usernames are the same, then the euid line is not printed. If real and effective groupnames are the same, then the rgid line is not printed. If a 'user is specified on the command line, then only the uid and groups lines are printed.

Note that getlogin(2) always returns a fully qualified user name (domain+user). Fully qualified names for real_user_name, effective_user_name, real_group_name, and group_list may or not be displayed depending if the name is from the principal domain or not. Use the -D option to force the use of fully qualified names.

-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 traditional Berkeley Software Distribution (BSD) command whoami(1) is the same as

id -un

DIAGNOSTICS

The id(1) utility exits 0 on success, and >0 if an error occurs.

SEE ALSO

logname(1)

getpwuid(2)

getuid(2)

geteuid(2)

getgrgid(2)

getgid(2)