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
23

DESCRIPTION

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

OPTIONS

41       The  id  utility  shall  conform  to  the  Base  Definitions  volume of
42       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
43
44       The following options shall be supported:
45
46       -G     Output all different group IDs (effective, real, and  supplemen‐
47              tary)  only, using the format "%u\n" . If there is more than one
48              distinct group affiliation, output each such affiliation,  using
49              the format " %u", before the <newline> is output.
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
60

OPERANDS

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

STDIN

68       Not used.
69

INPUT FILES

71       None.
72

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

101       Default.
102

STDOUT

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

STDERR

170       The standard error shall be used only for diagnostic messages.
171

OUTPUT FILES

173       None.
174

EXTENDED DESCRIPTION

176       None.
177

EXIT STATUS

179       The following exit values shall be returned:
180
181        0     Successful completion.
182
183       >0     An error occurred.
184
185

CONSEQUENCES OF ERRORS

187       Default.
188
189       The following sections are informative.
190

APPLICATION USAGE

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

EXAMPLES

205       None.
206

RATIONALE

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

FUTURE DIRECTIONS

231       None.
232

SEE ALSO

234       fold,    logname,    who,    the    System    Interfaces    volume   of
235       IEEE Std 1003.1-2001, getgid(), getgroups(), getuid()
236
238       Portions of this text are reprinted and reproduced in  electronic  form
239       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
240       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
241       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
242       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
243       event of any discrepancy between this version and the original IEEE and
244       The Open Group Standard, the original IEEE and The Open Group  Standard
245       is  the  referee document. The original Standard can be obtained online
246       at http://www.opengroup.org/unix/online.html .
247
248
249
250IEEE/The Open Group                  2003                               ID(1P)
Impressum