1ID(P) POSIX Programmer's Manual ID(P)
2
3
4
6 id - return user identity
7
9 id [user]
10
11 id -G[-n] [user]
12
13 id -g[-nr] [user]
14
15 id -u[-nr] [user]
16
17
19 If no user operand is provided, the id utility shall write the user and
20 group IDs and the corresponding user and group names of the invoking
21 process to standard output. If the effective and real IDs do not match,
22 both shall be written. If multiple groups are supported by the underly‐
23 ing system (see the description of {NGROUPS_MAX} in the System Inter‐
24 faces volume of IEEE Std 1003.1-2001), the supplementary group affilia‐
25 tions of the invoking process shall also be written.
26
27 If a user operand is provided and the process has the appropriate priv‐
28 ileges, the user and group IDs of the selected user shall be written.
29 In this case, effective IDs shall be assumed to be identical to real
30 IDs. If the selected user has more than one allowable group membership
31 listed in the group database, these shall be written in the same manner
32 as the supplementary groups described in the preceding paragraph.
33
35 The id utility shall conform to the Base Definitions volume of
36 IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
37
38 The following options shall be supported:
39
40 -G Output all different group IDs (effective, real, and supplemen‐
41 tary) only, using the format "%u\n" . If there is more than one
42 distinct group affiliation, output each such affiliation, using
43 the format " %u" , before the <newline> is output.
44
45 -g Output only the effective group ID, using the format "%u\n" .
46
47 -n Output the name in the format "%s" instead of the numeric ID
48 using the format "%u" .
49
50 -r Output the real ID instead of the effective ID.
51
52 -u Output only the effective user ID, using the format "%u\n" .
53
54
56 The following operand shall be supported:
57
58 user The login name for which information is to be written.
59
60
62 Not used.
63
65 None.
66
68 The following environment variables shall affect the execution of id:
69
70 LANG Provide a default value for the internationalization variables
71 that are unset or null. (See the Base Definitions volume of
72 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
73 ables for the precedence of internationalization variables used
74 to determine the values of locale categories.)
75
76 LC_ALL If set to a non-empty string value, override the values of all
77 the other internationalization variables.
78
79 LC_CTYPE
80 Determine the locale for the interpretation of sequences of
81 bytes of text data as characters (for example, single-byte as
82 opposed to multi-byte characters in arguments).
83
84 LC_MESSAGES
85 Determine the locale that should be used to affect the format
86 and contents of diagnostic messages written to standard error
87 and informative messages written to standard output.
88
89 NLSPATH
90 Determine the location of message catalogs for the processing of
91 LC_MESSAGES .
92
93
95 Default.
96
98 The following formats shall be used when the LC_MESSAGES locale cate‐
99 gory specifies the POSIX locale. In other locales, the strings uid,
100 gid, euid, egid, and groups may be replaced with more appropriate
101 strings corresponding to the locale.
102
103
104 "uid=%u(%s) gid=%u(%s)\n", <real user ID>, <user-name>,
105 <real group ID>, <group-name>
106
107 If the effective and real user IDs do not match, the following shall be
108 inserted immediately before the '\n' character in the previous format:
109
110
111 " euid=%u(%s)"
112
113 with the following arguments added at the end of the argument list:
114
115
116 <effective user ID>, <effective user-name>
117
118 If the effective and real group IDs do not match, the following shall
119 be inserted directly before the '\n' character in the format string
120 (and after any addition resulting from the effective and real user IDs
121 not matching):
122
123
124 " egid=%u(%s)"
125
126 with the following arguments added at the end of the argument list:
127
128
129 <effective group-ID>, <effective group name>
130
131 If the process has supplementary group affiliations or the selected
132 user is allowed to belong to multiple groups, the first shall be added
133 directly before the <newline> in the format string:
134
135
136 " groups=%u(%s)"
137
138 with the following arguments added at the end of the argument list:
139
140
141 <supplementary group ID>, <supplementary group name>
142
143 and the necessary number of the following added after that for any
144 remaining supplementary group IDs:
145
146
147 ",%u(%s)"
148
149 and the necessary number of the following arguments added at the end of
150 the argument list:
151
152
153 <supplementary group ID>, <supplementary group name>
154
155 If any of the user ID, group ID, effective user ID, effective group ID,
156 or supplementary/multiple group IDs cannot be mapped by the system into
157 printable user or group names, the corresponding "(%s)" and name argu‐
158 ment shall be omitted from the corresponding format string.
159
160 When any of the options are specified, the output format shall be as
161 described in the OPTIONS section.
162
164 The standard error shall be used only for diagnostic messages.
165
167 None.
168
170 None.
171
173 The following exit values shall be returned:
174
175 0 Successful completion.
176
177 >0 An error occurred.
178
179
181 Default.
182
183 The following sections are informative.
184
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
199 None.
200
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
225 None.
226
228 fold , logname , who , the System Interfaces volume of
229 IEEE Std 1003.1-2001, getgid(), getgroups(), getuid()
230
232 Portions of this text are reprinted and reproduced in electronic form
233 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
234 -- Portable Operating System Interface (POSIX), The Open Group Base
235 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
236 Electrical and Electronics Engineers, Inc and The Open Group. In the
237 event of any discrepancy between this version and the original IEEE and
238 The Open Group Standard, the original IEEE and The Open Group Standard
239 is the referee document. The original Standard can be obtained online
240 at http://www.opengroup.org/unix/online.html .
241
242
243
244IEEE/The Open Group 2003 ID(P)