The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

id - return user identity

 SYNOPSIS



id [user]

id -G[-n] [user]

id -g[-nr] [user]

id -u[-nr] [user]

 DESCRIPTION

If no user operand is provided, the id utility will write the user and group IDs and the corresponding user and group names of the invoking process to standard output. If the effective and real IDs do not match, both will be written. If multiple groups are supported by the underlying system (see the description of {NGROUPS_MAX} in the XSH specification), the supplementary group affiliations of the invoking process also will be written.

If a user operand is provided and the process has the appropriate privileges, the user and group IDs of the selected user will be written. In this case, effective IDs will be assumed to be identical to real IDs. If the selected user has more than one allowable group membership listed in the group database, these will be written in the same manner as the supplementary groups described in the preceding paragraph.

 OPTIONS

The id utility supports the XBD specification, Utility Syntax Guidelines  .

The following options are supported:

-G
Output all different group IDs (effective, real and supplementary) only, using the format %u\n. If there is more than one distinct group affiliation, output each such affiliation, using the format  %u, before the newline character is output.
-g
Output only the effective group ID, using the format %u\n.
-n
Output the name in the format %s instead of the numeric ID using the format %u.
-r
Output the real ID instead of the effective ID.
-u
Output only the effective user ID, using the format %u\n.

 OPERANDS

The following operand is supported:
user
The login name for which information is to be written.

 STDIN

Not used.

 INPUT FILES

None.

 ENVIRONMENT VARIABLES

The following environment variables affect the execution of id:
LANG
Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation 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 internationalisation 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).
LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and informative messages written to standard output.
NLSPATH
Determine the location of message catalogues for the processing of LC_MESSAGES .

 ASYNCHRONOUS EVENTS

Default.

 STDOUT

The following formats will be used when the LC_MESSAGES locale category specifies the POSIX locale. In other locales, the strings uid, gid, euid, egid and groups may be replaced with more appropriate strings corresponding to the locale.

"uid=%u(%s) gid=%u(%s)\n", <real user ID>,
<user-name>,
<real group ID>,
<group-name>

If the effective and real user IDs do not match, the following will be inserted immediately before the \n character in the previous format:


" euid=%u(%s)"

with the following arguments added at the end of the argument list:

<effective user ID>,
<effective user-name>

If the effective and real group IDs do not match, the following will be inserted directly before the \n character in the format string (and after any addition resulting from the effective and real user IDs not matching):


" egid=%u(%s)"

with the following arguments added at the end of the argument list:

<effective group-ID>,
<effective group name>

If the process has supplementary group affiliations or the selected user is allowed to belong to multiple groups, the first will be added directly before the newline character in the format string:


" groups=%u(%s)"

with the following arguments added at the end of the argument list:

<supplementary group ID>, <supplementary group name> and the necessary number of the following added after that for any remaining supplementary group IDs:

,%u(%s) and the necessary number of the following arguments added at the end of the argument list:

<supplementary group ID>, <supplementary group name>

If any of the user ID, group ID, effective user ID, effective group ID or supplementary/multiple group IDs cannot be mapped by the system into printable user or group names, the corresponding (%s) and name argument will be omitted from the corresponding format string.

When any of the options are specified, the output format will be as described in the OPTIONS section.

 STDERR

Used only for diagnostic messages.

 OUTPUT FILES

None.

 EXTENDED DESCRIPTION

None.

 EXIT STATUS

The following exit values are returned:
0
Successful completion.
>0
An error occurred.

 CONSEQUENCES OF ERRORS

Default.

 APPLICATION USAGE

Output produced by the -G option and by the default case could potentially produce very long lines on systems that support large numbers of supplementary groups. (On systems with user and group IDs that are 32-bit integers and with group names with a maximum of 8 bytes per name, 93 supplementary groups plus distinct effective and real group and user IDs could theoretically overflow the 2048-byte {LINE_MAX} text file line limit on the default output case. It would take about 186 supplementary groups to overflow the 2048-byte barrier using id -G). This is not expected to be a problem in practice, but in cases where it is a concern, applications should consider using fold -s before postprocessing the output of id.

 EXAMPLES

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

fold, logname, who, the XSH specification description of getgid(), getgroups(), getuid().

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]