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
11

NAME

13       id — return user identity
14

SYNOPSIS

16       id [user]
17
18       id −G [−n] [user]
19
20       id −g [−nr] [user]
21
22       id −u [−nr] [user]
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 POSIX.1‐2008), the supplementary group affiliations of
31       the invoking process shall also be written.
32
33       If a user operand is provided and the process  has  appropriate  privi‐
34       leges, the user and group IDs of the selected user shall be written. In
35       this case, effective IDs shall be assumed to be identical to real  IDs.
36       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       POSIX.1‐2008, 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  supple‐
47                 mentary)  only,  using  the  format "%u\n".  If there is more
48                 than one distinct group affiliation, output each such affili‐
49                 ation,  using  the format " %u", before the <newline> is out‐
50                 put.
51
52       −g        Output only the effective group ID, using the format "%u\n".
53
54       −n        Output the name in the format "%s" instead of the numeric  ID
55                 using the format "%u".
56
57       −r        Output the real ID instead of the effective ID.
58
59       −u        Output only the effective user ID, using the format "%u\n".
60

OPERANDS

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

STDIN

67       Not used.
68

INPUT FILES

70       None.
71

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

97       Default.
98

STDOUT

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

STDERR

157       The standard error shall be used only for diagnostic messages.
158

OUTPUT FILES

160       None.
161

EXTENDED DESCRIPTION

163       None.
164

EXIT STATUS

166       The following exit values shall be returned:
167
168        0    Successful completion.
169
170       >0    An error occurred.
171

CONSEQUENCES OF ERRORS

173       Default.
174
175       The following sections are informative.
176

APPLICATION USAGE

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

EXAMPLES

191       None.
192

RATIONALE

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

FUTURE DIRECTIONS

215       None.
216

SEE ALSO

218       fold, logname, who
219
220       The Base Definitions volume of  POSIX.1‐2008,  Chapter  8,  Environment
221       Variables, Section 12.2, Utility Syntax Guidelines
222
223       The  System  Interfaces  volume of POSIX.1‐2008, getgid(), getgroups(),
224       getuid()
225
227       Portions of this text are reprinted and reproduced in  electronic  form
228       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
229       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
230       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
231       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
232       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
233       event of any discrepancy between this version and the original IEEE and
234       The  Open Group Standard, the original IEEE and The Open Group Standard
235       is the referee document. The original Standard can be  obtained  online
236       at http://www.unix.org/online.html .
237
238       Any  typographical  or  formatting  errors that appear in this page are
239       most likely to have been introduced during the conversion of the source
240       files  to  man page format. To report such errors, see https://www.ker
241       nel.org/doc/man-pages/reporting_bugs.html .
242
243
244
245IEEE/The Open Group                  2013                               ID(1P)
Impressum