xref: /freebsd/usr.bin/id/id.1 (revision df21a004be237a1dccd03c7b47254625eea62fa9)
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 October 23, 2025
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 d
54.Op Ar user
55.Nm
56.Fl g Op Fl nr
57.Op Ar user
58.Nm
59.Fl p
60.Op Ar user
61.Nm
62.Fl s
63.Op Ar user
64.Nm
65.Fl u Op Fl nr
66.Op Ar user
67.Sh DESCRIPTION
68The
69.Nm
70utility displays the user and group names and numeric IDs, of the
71calling process, to the standard output.
72If the real and effective IDs are different, both are displayed,
73otherwise only the real ID is displayed.
74.Pp
75If a
76.Ar user
77(login name or user ID)
78is specified, the user and group IDs of that user are displayed.
79In this case, the real and effective IDs are assumed to be the same.
80.Pp
81The options are as follows:
82.Bl -tag -width indent
83.It Fl A
84Display the process audit user ID and other process audit properties, which
85requires privilege.
86.It Fl G
87Display the different group IDs (effective, real and supplementary)
88as white-space separated numbers, in no particular order.
89.It Fl M
90Display the MAC label of the current process.
91.It Fl P
92Display the id as a password file entry.
93.It Fl a
94Ignored for compatibility with other
95.Nm
96implementations.
97.It Fl c
98Display current login class.
99.It Fl d
100Display the home directory of the current or specified user.
101.It Fl g
102Display the effective group ID as a number.
103.It Fl n
104Display the name of the user or group ID for the
105.Fl G ,
106.Fl g
107and
108.Fl u
109options instead of the number.
110If any of the ID numbers cannot be mapped into names, the number will be
111displayed as usual.
112.It Fl p
113Make the output human-readable.
114If the user name returned by
115.Xr getlogin 2
116is different from the login name referenced by the user ID, the name
117returned by
118.Xr getlogin 2
119is displayed, preceded by the keyword
120.Dq login .
121The user ID as a name is displayed, preceded by the keyword
122.Dq uid .
123If the effective user ID is different from the real user ID, the real user
124ID is displayed as a name, preceded by the keyword
125.Dq euid .
126If the effective group ID is different from the real group ID, the real group
127ID is displayed as a name, preceded by the keyword
128.Dq rgid .
129The list of groups to which the user belongs is then displayed as names,
130preceded by the keyword
131.Dq groups .
132Each display is on a separate line.
133.It Fl r
134Display the real ID for the
135.Fl g
136and
137.Fl u
138options instead of the effective ID.
139.It Fl s
140Display the shell of the current or specified user.
141.It Fl u
142Display the effective user ID as a number.
143.El
144.Sh EXIT STATUS
145.Ex -std
146.Sh EXAMPLES
147Show information for the user
148.Ql bob
149as a password file entry:
150.Bd -literal -offset indent
151$ id -P bob
152bob:*:0:0::0:0:Robert:/bob:/usr/local/bin/bash
153.Ed
154.Pp
155Same output as
156.Xr groups 1 for the root user:
157.Bd -literal -offset indent
158$ id -Gn root
159wheel operator
160.Ed
161.Pp
162Show human readable information about
163.Ql alice :
164.Bd -literal -offset indent
165$ id -p alice
166uid     alice
167groups  alice webcamd vboxusers
168.Ed
169.Pp
170Assuming the user
171.Ql bob
172executed
173.Dq Nm su Fl l
174to simulate a root login, compare the result of the following commands:
175.Bd -literal -offset indent
176# id -un
177root
178# who am i
179bob          pts/5        Dec  4 19:51
180.Ed
181.Sh SEE ALSO
182.Xr groups 1 ,
183.Xr who 1
184.Sh STANDARDS
185The
186.Nm
187utility is expected to conform to
188.St -p1003.1-2024 .
189The
190.Fl A ,
191.Fl M ,
192.Fl P ,
193.Fl c ,
194.Fl d ,
195.Fl p ,
196and
197.Fl s
198options are
199.Fx
200extensions.
201.Sh HISTORY
202The
203historic
204.Xr groups 1
205command is equivalent to
206.Dq Nm id Fl Gn Op Ar user .
207.Pp
208The
209historic
210.Xr whoami 1
211command is equivalent to
212.Dq Nm id Fl un .
213.Pp
214The
215.Nm
216command appeared in
217.Bx 4.4 .
218