xref: /openbsd/usr.bin/id/id.1 (revision 3bef86f7)
1.\"	$OpenBSD: id.1,v 1.21 2022/07/25 02:25:55 jsg Exp $
2.\"	$NetBSD: id.1,v 1.5 1995/09/28 08:05:40 perry Exp $
3.\"
4.\" Copyright (c) 1991, 1993, 1994
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" This code is derived from software contributed to Berkeley by
8.\" the Institute of Electrical and Electronics Engineers, Inc.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\" 3. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"	@(#)id.1	8.2 (Berkeley) 5/5/94
35.\"
36.Dd $Mdocdate: July 25 2022 $
37.Dt ID 1
38.Os
39.Sh NAME
40.Nm id
41.Nd return user identity
42.Sh SYNOPSIS
43.Nm id
44.Op Ar user
45.Nm id
46.Fl c
47.Op Ar user
48.Nm id
49.Fl G Op Fl n
50.Op Ar user
51.Nm id
52.Fl g Op Fl nr
53.Op Ar user
54.Nm id
55.Fl p
56.Op Ar user
57.Nm id
58.Fl R
59.Nm id
60.Fl u Op Fl nr
61.Op Ar user
62.Sh DESCRIPTION
63The
64.Nm
65utility displays the user and group names and numeric IDs, of the
66calling process, to the standard output.
67If the real and effective IDs are different, both are displayed,
68otherwise only the real ID is displayed.
69.Pp
70If a
71.Ar user
72(login name or user ID)
73is specified, the user and group IDs of that user are displayed.
74In this case, the real and effective IDs are assumed to be the same.
75.Pp
76The options are as follows:
77.Bl -tag -width Ds
78.It Fl c
79Display the login class of the real user ID or the specified
80.Ar user .
81.It Fl G
82Display the different group IDs (effective, real and supplementary)
83as whitespace separated numbers, in no particular order.
84.It Fl g
85Display the effective group ID as a number.
86.It Fl n
87Display the name of the user or group ID for the
88.Fl G ,
89.Fl g
90and
91.Fl u
92options instead of the number.
93If any of the ID numbers cannot be mapped into names, the number will be
94displayed as usual.
95.It Fl p
96Make the output human-readable.
97If the user name returned by
98.Xr getlogin 2
99is different from the login name referenced by the user ID, the name
100returned by
101.Xr getlogin 2
102is displayed, preceded by the keyword
103.Dq login .
104The user ID as a name is displayed, preceded by the keyword
105.Dq uid .
106If the effective user ID is different from the real user ID, the real user
107ID is displayed as a name, preceded by the keyword
108.Dq euid .
109If the effective group ID is different from the real group ID, the real group
110ID is displayed as a name, preceded by the keyword
111.Dq rgid .
112The list of groups to which the user belongs is then displayed as names,
113preceded by the keyword
114.Dq groups .
115If there is a login class specified for the user in the
116.Xr passwd 5
117database, it is displayed, preceded by the keyword
118.Dq class .
119Each display is on a separate line.
120.It Fl R
121Display the routing table of the current process.
122.It Fl r
123Display the real ID for the
124.Fl g
125and
126.Fl u
127options instead of the effective ID.
128.It Fl u
129Display the effective user ID as a number.
130.El
131.Sh EXIT STATUS
132.Ex -std id
133.Sh SEE ALSO
134.Xr who 1 ,
135.Xr login.conf 5
136.Sh STANDARDS
137The
138.Nm
139utility is compliant with the
140.St -p1003.1-2008
141specification.
142.Pp
143The flags
144.Op Fl cpR
145are extensions to that specification.
146.Sh HISTORY
147The
148historic
149.Xr groups 1
150command is equivalent to
151.Ic id Fl Gn Op Ar user .
152.Pp
153The
154historic
155.Xr whoami 1
156command is equivalent to
157.Ic id Fl un .
158.Pp
159The
160.Nm
161command first appeared in
162.At III
163and was reimplemented for
164.Bx 4.3 Net/2 .
165