xref: /freebsd/usr.bin/id/id.1 (revision 3494f7c0)
1.\" Copyright (c) 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the Institute of Electrical and Electronics Engineers, Inc.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.Dd March 5, 2011
32.Dt ID 1
33.Os
34.Sh NAME
35.Nm id
36.Nd return user identity
37.Sh SYNOPSIS
38.Nm
39.Op Ar user
40.Nm
41.Fl A
42.Nm
43.Fl G Op Fl n
44.Op Ar user
45.Nm
46.Fl M
47.Nm
48.Fl P
49.Op Ar user
50.Nm
51.Fl c
52.Nm
53.Fl g Op Fl nr
54.Op Ar user
55.Nm
56.Fl p
57.Op Ar user
58.Nm
59.Fl u Op Fl nr
60.Op Ar user
61.Sh DESCRIPTION
62The
63.Nm
64utility displays the user and group names and numeric IDs, of the
65calling process, to the standard output.
66If the real and effective IDs are different, both are displayed,
67otherwise only the real ID is displayed.
68.Pp
69If a
70.Ar user
71(login name or user ID)
72is specified, the user and group IDs of that user are displayed.
73In this case, the real and effective IDs are assumed to be the same.
74.Pp
75The options are as follows:
76.Bl -tag -width indent
77.It Fl A
78Display the process audit user ID and other process audit properties, which
79requires privilege.
80.It Fl G
81Display the different group IDs (effective, real and supplementary)
82as white-space separated numbers, in no particular order.
83.It Fl M
84Display the MAC label of the current process.
85.It Fl P
86Display the id as a password file entry.
87.It Fl a
88Ignored for compatibility with other
89.Nm
90implementations.
91.It Fl c
92Display current login class.
93.It Fl g
94Display the effective group ID as a number.
95.It Fl n
96Display the name of the user or group ID for the
97.Fl G ,
98.Fl g
99and
100.Fl u
101options instead of the number.
102If any of the ID numbers cannot be mapped into names, the number will be
103displayed as usual.
104.It Fl p
105Make the output human-readable.
106If the user name returned by
107.Xr getlogin 2
108is different from the login name referenced by the user ID, the name
109returned by
110.Xr getlogin 2
111is displayed, preceded by the keyword
112.Dq login .
113The user ID as a name is displayed, preceded by the keyword
114.Dq uid .
115If the effective user ID is different from the real user ID, the real user
116ID is displayed as a name, preceded by the keyword
117.Dq euid .
118If the effective group ID is different from the real group ID, the real group
119ID is displayed as a name, preceded by the keyword
120.Dq rgid .
121The list of groups to which the user belongs is then displayed as names,
122preceded by the keyword
123.Dq groups .
124Each display is on a separate line.
125.It Fl r
126Display the real ID for the
127.Fl g
128and
129.Fl u
130options instead of the effective ID.
131.It Fl u
132Display the effective user ID as a number.
133.El
134.Sh EXIT STATUS
135.Ex -std
136.Sh EXAMPLES
137Show information for the user
138.Ql bob
139as a password file entry:
140.Bd -literal -offset indent
141$ id -P bob
142bob:*:0:0::0:0:Robert:/bob:/usr/local/bin/bash
143.Ed
144.Pp
145Same output as
146.Xr groups 1 for the root user:
147.Bd -literal -offset indent
148$ id -Gn root
149wheel operator
150.Ed
151.Pp
152Show human readable information about
153.Ql alice :
154.Bd -literal -offset indent
155$ id -p alice
156uid     alice
157groups  alice webcamd vboxusers
158.Ed
159.Pp
160Assuming the user
161.Ql bob
162executed
163.Dq Nm su Fl l
164to simulate a root login, compare the result of the following commands:
165.Bd -literal -offset indent
166# id -un
167root
168# who am i
169bob          pts/5        Dec  4 19:51
170.Ed
171.Sh SEE ALSO
172.Xr groups 1 ,
173.Xr who 1
174.Sh STANDARDS
175The
176.Nm
177function is expected to conform to
178.St -p1003.2 .
179.Sh HISTORY
180The
181historic
182.Xr groups 1
183command is equivalent to
184.Dq Nm id Fl Gn Op Ar user .
185.Pp
186The
187historic
188.Xr whoami 1
189command is equivalent to
190.Dq Nm id Fl un .
191.Pp
192The
193.Nm
194command appeared in
195.Bx 4.4 .
196