id.1p (9153B)
- '\" et
- .TH ID "1P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
- .\"
- .SH PROLOG
- This manual page is part of the POSIX Programmer's Manual.
- The Linux implementation of this interface may differ (consult
- the corresponding Linux manual page for details of Linux behavior),
- or the interface may not be implemented on Linux.
- .\"
- .SH NAME
- id
- \(em return user identity
- .SH SYNOPSIS
- .LP
- .nf
- id \fB[\fIuser\fB]\fR
- .P
- id -G \fB[\fR-n\fB] [\fIuser\fB]\fR
- .P
- id -g \fB[\fR-nr\fB] [\fIuser\fB]\fR
- .P
- id -u \fB[\fR-nr\fB] [\fIuser\fB]\fR
- .fi
- .SH DESCRIPTION
- If no
- .IR user
- operand is provided, the
- .IR 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 POSIX.1\(hy2017), the supplementary group affiliations of the invoking
- process shall also be written.
- .P
- If a
- .IR user
- operand is provided and the process has 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.
- .SH OPTIONS
- The
- .IR id
- utility shall conform to the Base Definitions volume of POSIX.1\(hy2017,
- .IR "Section 12.2" ", " "Utility Syntax Guidelines".
- .P
- The following options shall be supported:
- .IP "\fB\-G\fP" 10
- Output all different group IDs (effective, real, and supplementary)
- only, using the format
- .BR \(dq%u\en\(dq .
- If there is more than one distinct group affiliation, output each such
- affiliation, using the format
- .BR \(dq\ %u\(dq ,
- before the
- <newline>
- is output.
- .IP "\fB\-g\fP" 10
- Output only the effective group ID, using the format
- .BR \(dq%u\en\(dq .
- .IP "\fB\-n\fP" 10
- Output the name in the format
- .BR \(dq%s\(dq
- instead of the numeric ID using the format
- .BR \(dq%u\(dq .
- .IP "\fB\-r\fP" 10
- Output the real ID instead of the effective ID.
- .IP "\fB\-u\fP" 10
- Output only the effective user ID, using the format
- .BR \(dq%u\en\(dq .
- .SH OPERANDS
- The following operand shall be supported:
- .IP "\fIuser\fR" 10
- The login name for which information is to be written.
- .SH STDIN
- Not used.
- .SH "INPUT FILES"
- None.
- .SH "ENVIRONMENT VARIABLES"
- The following environment variables shall affect the execution of
- .IR id :
- .IP "\fILANG\fP" 10
- Provide a default value for the internationalization variables that are
- unset or null. (See the Base Definitions volume of POSIX.1\(hy2017,
- .IR "Section 8.2" ", " "Internationalization Variables"
- for the precedence of internationalization variables used to determine
- the values of locale categories.)
- .IP "\fILC_ALL\fP" 10
- If set to a non-empty string value, override the values of all the
- other internationalization variables.
- .IP "\fILC_CTYPE\fP" 10
- Determine the locale for the interpretation of sequences of bytes of
- text data as characters (for example, single-byte as opposed to
- multi-byte characters in arguments).
- .IP "\fILC_MESSAGES\fP" 10
- .br
- 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.
- .IP "\fINLSPATH\fP" 10
- Determine the location of message catalogs for the processing of
- .IR LC_MESSAGES .
- .SH "ASYNCHRONOUS EVENTS"
- Default.
- .SH STDOUT
- The following formats shall be used when the
- .IR LC_MESSAGES
- locale category specifies the POSIX locale. In other locales, the
- strings
- .IR uid ,
- .IR gid ,
- .IR euid ,
- .IR egid ,
- and
- .IR groups
- may be replaced with more appropriate strings corresponding to the
- locale.
- .sp
- .RS 4
- .nf
- "uid=%u(%s) gid=%u(%s)\en", <\fIreal user ID\fR>, <\fIuser-name\fR>,
- <\fIreal group ID\fR>, <\fIgroup-name\fR>
- .fi
- .P
- .RE
- .P
- If the effective and real user IDs do not match, the following shall be
- inserted immediately before the
- .BR '\en'
- character in the previous format:
- .sp
- .RS 4
- .nf
- " euid=%u(%s)"
- .fi
- .P
- .RE
- .P
- with the following arguments added at the end of the argument list:
- .sp
- .RS 4
- .nf
- <\fIeffective user ID\fR>, <\fIeffective user-name\fR>
- .fi
- .P
- .RE
- .P
- If the effective and real group IDs do not match, the following shall
- be inserted directly before the
- .BR '\en'
- character in the format string (and after any addition resulting from
- the effective and real user IDs not matching):
- .sp
- .RS 4
- .nf
- " egid=%u(%s)"
- .fi
- .P
- .RE
- .P
- with the following arguments added at the end of the argument list:
- .sp
- .RS 4
- .nf
- <\fIeffective group-ID\fR>, <\fIeffective group name\fR>
- .fi
- .P
- .RE
- .P
- 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:
- .sp
- .RS 4
- .nf
- " groups=%u(%s)"
- .fi
- .P
- .RE
- .P
- with the following arguments added at the end of the argument list:
- .sp
- .RS 4
- .nf
- <\fIsupplementary group ID\fR>, <\fIsupplementary group name\fR>
- .fi
- .P
- .RE
- .P
- and the necessary number of the following added after that for any
- remaining supplementary group IDs:
- .sp
- .RS 4
- .nf
- ",%u(%s)"
- .fi
- .P
- .RE
- .P
- and the necessary number of the following arguments added at the end of
- the argument list:
- .sp
- .RS 4
- .nf
- <\fIsupplementary group ID\fR>, <\fIsupplementary group name\fR>
- .fi
- .P
- .RE
- .P
- 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
- .BR \(dq(%s)\(dq
- and
- .IR name
- argument shall be omitted from the corresponding format string.
- .P
- When any of the options are specified, the output format shall be as
- described in the OPTIONS section.
- .SH STDERR
- The standard error shall be used only for diagnostic messages.
- .SH "OUTPUT FILES"
- None.
- .SH "EXTENDED DESCRIPTION"
- None.
- .SH "EXIT STATUS"
- The following exit values shall be returned:
- .IP "\00" 6
- Successful completion.
- .IP >0 6
- An error occurred.
- .SH "CONSEQUENCES OF ERRORS"
- Default.
- .LP
- .IR "The following sections are informative."
- .SH "APPLICATION USAGE"
- Output produced by the
- .BR \-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 2\|048-byte
- {LINE_MAX}
- text file line limit on the default output case. It would take about
- 186 supplementary groups to overflow the 2\|048-byte barrier using
- .IR id
- .BR \-G ).
- This is not expected to be a problem in practice, but in cases where it
- is a concern, applications should consider using
- .IR fold
- .BR \-s
- before post-processing the output of
- .IR id .
- .SH EXAMPLES
- None.
- .SH RATIONALE
- The functionality provided by the 4 BSD
- .IR groups
- utility can be simulated using:
- .sp
- .RS 4
- .nf
- id -Gn [ user ]
- .fi
- .P
- .RE
- .P
- The 4 BSD command
- .IR groups
- was considered, but it was not included because it did not provide the
- functionality of the
- .IR id
- utility of the SVID. Also, it was thought that it would be easier to
- modify
- .IR id
- to provide the additional functionality necessary to systems with
- multiple groups than to invent another command.
- .P
- The options
- .BR \-u ,
- .BR \-g ,
- .BR \-n ,
- and
- .BR \-r
- were added to ease the use of
- .IR id
- with shell commands substitution. Without these options it is
- necessary to use some preprocessor such as
- .IR sed
- to select the desired piece of information. Since output such as that
- produced by:
- .sp
- .RS 4
- .nf
- id -u -n
- .fi
- .P
- .RE
- .P
- is frequently wanted, it seemed desirable to add the options.
- .SH "FUTURE DIRECTIONS"
- None.
- .SH "SEE ALSO"
- .IR "\fIfold\fR\^",
- .IR "\fIlogname\fR\^",
- .IR "\fIwho\fR\^"
- .P
- The Base Definitions volume of POSIX.1\(hy2017,
- .IR "Chapter 8" ", " "Environment Variables",
- .IR "Section 12.2" ", " "Utility Syntax Guidelines"
- .P
- The System Interfaces volume of POSIX.1\(hy2017,
- .IR "\fIgetgid\fR\^(\|)",
- .IR "\fIgetgroups\fR\^(\|)",
- .IR "\fIgetuid\fR\^(\|)"
- .\"
- .SH COPYRIGHT
- Portions of this text are reprinted and reproduced in electronic form
- from IEEE Std 1003.1-2017, Standard for Information Technology
- -- Portable Operating System Interface (POSIX), The Open Group Base
- Specifications Issue 7, 2018 Edition,
- Copyright (C) 2018 by the Institute of
- Electrical and Electronics Engineers, Inc and The Open Group.
- In the event of any discrepancy between this version and the original IEEE and
- The Open Group Standard, the original IEEE and The Open Group Standard
- is the referee document. The original Standard can be obtained online at
- http://www.opengroup.org/unix/online.html .
- .PP
- Any typographical or formatting errors that appear
- in this page are most likely
- to have been introduced during the conversion of the source files to
- man page format. To report such errors, see
- https://www.kernel.org/doc/man-pages/reporting_bugs.html .