1ID(1P)                     POSIX Programmer's Manual                    ID(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       id — return user identity
13

SYNOPSIS

15       id [user]
16
17       id -G [-n] [user]
18
19       id -g [-nr] [user]
20
21       id -u [-nr] [user]
22

DESCRIPTION

24       If no user operand is provided, the id utility shall write the user and
25       group  IDs  and  the corresponding user and group names of the invoking
26       process to standard output. If the effective and real IDs do not match,
27       both shall be written. If multiple groups are supported by the underly‐
28       ing system (see the description of {NGROUPS_MAX} in the  System  Inter‐
29       faces  volume of POSIX.1‐2017), the supplementary group affiliations of
30       the invoking process shall also be written.
31
32       If a user operand is provided and the process  has  appropriate  privi‐
33       leges, the user and group IDs of the selected user shall be written. In
34       this case, effective IDs shall be assumed to be identical to real  IDs.
35       If  the  selected  user  has  more  than one allowable group membership
36       listed in the group database, these shall be written in the same manner
37       as the supplementary groups described in the preceding paragraph.
38

OPTIONS

40       The  id  utility  shall  conform  to  the  Base  Definitions  volume of
41       POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines.
42
43       The following options shall be supported:
44
45       -G        Output all different group IDs (effective, real, and  supple‐
46                 mentary)  only,  using  the  format "%u\n".  If there is more
47                 than one distinct group affiliation, output each such affili‐
48                 ation,  using  the format " %u", before the <newline> is out‐
49                 put.
50
51       -g        Output only the effective group ID, using the format "%u\n".
52
53       -n        Output the name in the format "%s" instead of the numeric  ID
54                 using the format "%u".
55
56       -r        Output the real ID instead of the effective ID.
57
58       -u        Output only the effective user ID, using the format "%u\n".
59

OPERANDS

61       The following operand shall be supported:
62
63       user      The login name for which information is to be written.
64

STDIN

66       Not used.
67

INPUT FILES

69       None.
70

ENVIRONMENT VARIABLES

72       The following environment variables shall affect the execution of id:
73
74       LANG      Provide  a  default  value for the internationalization vari‐
75                 ables that are unset or null. (See the Base Definitions  vol‐
76                 ume  of POSIX.1‐2017, Section 8.2, Internationalization Vari‐
77                 ables for the precedence  of  internationalization  variables
78                 used to determine the values of locale categories.)
79
80       LC_ALL    If  set  to  a non-empty string value, override the values of
81                 all the other internationalization variables.
82
83       LC_CTYPE  Determine the locale for the interpretation of  sequences  of
84                 bytes of text data as characters (for example, single-byte as
85                 opposed to multi-byte characters in arguments).
86
87       LC_MESSAGES
88                 Determine the locale that should be used to affect the format
89                 and contents of diagnostic messages written to standard error
90                 and informative messages written to standard output.
91
92       NLSPATH   Determine the location of message catalogs for the processing
93                 of LC_MESSAGES.
94

ASYNCHRONOUS EVENTS

96       Default.
97

STDOUT

99       The  following  formats shall be used when the LC_MESSAGES locale cate‐
100       gory specifies the POSIX locale. In other  locales,  the  strings  uid,
101       gid,  euid,  egid,  and  groups  may  be replaced with more appropriate
102       strings corresponding to the locale.
103
104
105           "uid=%u(%s) gid=%u(%s)\n", <real user ID>, <user-name>,
106               <real group ID>, <group-name>
107
108       If the effective and real user IDs do not match, the following shall be
109       inserted immediately before the '\n' character in the previous format:
110
111
112           " euid=%u(%s)"
113
114       with the following arguments added at the end of the argument list:
115
116
117           <effective user ID>, <effective user-name>
118
119       If  the  effective and real group IDs do not match, the following shall
120       be inserted directly before the '\n' character  in  the  format  string
121       (and  after any addition resulting from the effective and real user IDs
122       not matching):
123
124
125           " egid=%u(%s)"
126
127       with the following arguments added at the end of the argument list:
128
129
130           <effective group-ID>, <effective group name>
131
132       If the process has supplementary group  affiliations  or  the  selected
133       user  is allowed to belong to multiple groups, the first shall be added
134       directly before the <newline> in the format string:
135
136
137           " groups=%u(%s)"
138
139       with the following arguments added at the end of the argument list:
140
141
142           <supplementary group ID>, <supplementary group name>
143
144       and the necessary number of the following  added  after  that  for  any
145       remaining supplementary group IDs:
146
147
148           ",%u(%s)"
149
150       and the necessary number of the following arguments added at the end of
151       the argument list:
152
153
154           <supplementary group ID>, <supplementary group name>
155
156       If any of the user ID, group ID, effective user ID, effective group ID,
157       or supplementary/multiple group IDs cannot be mapped by the system into
158       printable user or group names, the corresponding "(%s)" and name  argu‐
159       ment shall be omitted from the corresponding format string.
160
161       When  any  of  the options are specified, the output format shall be as
162       described in the OPTIONS section.
163

STDERR

165       The standard error shall be used only for diagnostic messages.
166

OUTPUT FILES

168       None.
169

EXTENDED DESCRIPTION

171       None.
172

EXIT STATUS

174       The following exit values shall be returned:
175
176        0    Successful completion.
177
178       >0    An error occurred.
179

CONSEQUENCES OF ERRORS

181       Default.
182
183       The following sections are informative.
184

APPLICATION USAGE

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

EXAMPLES

199       None.
200

RATIONALE

202       The functionality provided by the 4 BSD groups utility can be simulated
203       using:
204
205
206           id -Gn [ user ]
207
208       The  4  BSD  command  groups  was  considered,  but it was not included
209       because it did not provide the functionality of the id utility  of  the
210       SVID. Also, it was thought that it would be easier to modify id to pro‐
211       vide the additional functionality necessary to  systems  with  multiple
212       groups than to invent another command.
213
214       The  options  -u,  -g, -n, and -r were added to ease the use of id with
215       shell commands substitution. Without these options it is  necessary  to
216       use some preprocessor such as sed to select the desired piece of infor‐
217       mation. Since output such as that produced by:
218
219
220           id -u -n
221
222       is frequently wanted, it seemed desirable to add the options.
223

FUTURE DIRECTIONS

225       None.
226

SEE ALSO

228       fold, logname, who
229
230       The Base Definitions volume of  POSIX.1‐2017,  Chapter  8,  Environment
231       Variables, Section 12.2, Utility Syntax Guidelines
232
233       The  System  Interfaces  volume of POSIX.1‐2017, getgid(), getgroups(),
234       getuid()
235
237       Portions of this text are reprinted and reproduced in  electronic  form
238       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
239       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
240       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
241       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
242       event of any discrepancy between this version and the original IEEE and
243       The Open Group Standard, the original IEEE and The Open Group  Standard
244       is  the  referee document. The original Standard can be obtained online
245       at http://www.opengroup.org/unix/online.html .
246
247       Any typographical or formatting errors that appear  in  this  page  are
248       most likely to have been introduced during the conversion of the source
249       files to man page format. To report such errors,  see  https://www.ker
250       nel.org/doc/man-pages/reporting_bugs.html .
251
252
253
254IEEE/The Open Group                  2017                               ID(1P)
Impressum