If no user operand is provided, the id utility shall 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 shall be written. If
multiple groups are supported by the underlying system (see the description
of {NGROUPS_MAX} in the System Interfaces volume of
IEEE Std 1003.1-2001), the supplementary group affiliations of the
invoking process shall also be written.
If a user operand is provided and the process has the appropriate
privileges, the user and group IDs of the selected user
shall be written. In this case, effective IDs shall 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 shall
be written in the same manner as the supplementary groups
described in the preceding paragraph.
The following formats shall 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 shall
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 shall
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
shall be added directly before the <newline> 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 shall be omitted from the
corresponding format string.
When any of the options are specified, the output format shall be
as described in the OPTIONS section.
The functionality provided by the 4 BSD groups utility can be
simulated using:
id -Gn [ user ]
The 4 BSD command groups was considered, but it was not included
because it did not provide the functionality of the
id utility of the SVID. Also, it was thought that it would be
easier to modify id to provide the additional
functionality necessary to systems with multiple groups than to invent
another command.
The options -u, -g, -n, and -r were added
to ease the use of id with shell commands
substitution. Without these options it is necessary to use some preprocessor
such as sed
to select the desired piece of information. Since output such as that
produced by:
id -u -n
is frequently wanted, it seemed desirable to add the options.