xref: /openbsd-src/usr.bin/id/id.1 (revision 91f110e064cd7c194e59e019b83bb7496c1c84d4)
1.\"	$OpenBSD: id.1,v 1.17 2010/09/03 11:09:29 jmc 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: September 3 2010 $
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 G Op Fl n
47.Op Ar user
48.Nm id
49.Fl g Op Fl nr
50.Op Ar user
51.Nm id
52.Fl p
53.Op Ar user
54.Nm id
55.Fl u Op Fl nr
56.Op Ar user
57.Sh DESCRIPTION
58The
59.Nm
60utility displays the user and group names and numeric IDs, of the
61calling process, to the standard output.
62If the real and effective IDs are different, both are displayed,
63otherwise only the real ID is displayed.
64.Pp
65If a
66.Ar user
67(login name or user ID)
68is specified, the user and group IDs of that user are displayed.
69In this case, the real and effective IDs are assumed to be the same.
70.Pp
71The options are as follows:
72.Bl -tag -width Ds
73.It Fl G
74Display the different group IDs (effective, real and supplementary)
75as whitespace separated numbers, in no particular order.
76.It Fl g
77Display the effective group ID as a number.
78.It Fl n
79Display the name of the user or group ID for the
80.Fl G ,
81.Fl g
82and
83.Fl u
84options instead of the number.
85If any of the ID numbers cannot be mapped into names, the number will be
86displayed as usual.
87.It Fl p
88Make the output human-readable.
89If the user name returned by
90.Xr getlogin 2
91is different from the login name referenced by the user ID, the name
92returned by
93.Xr getlogin 2
94is displayed, preceded by the keyword
95.Dq login .
96The user ID as a name is displayed, preceded by the keyword
97.Dq uid .
98If the effective user ID is different from the real user ID, the real user
99ID is displayed as a name, preceded by the keyword
100.Dq euid .
101If the effective group ID is different from the real group ID, the real group
102ID is displayed as a name, preceded by the keyword
103.Dq rgid .
104The list of groups to which the user belongs is then displayed as names,
105preceded by the keyword
106.Dq groups .
107Each display is on a separate line.
108.It Fl r
109Display the real ID for the
110.Fl g
111and
112.Fl u
113options instead of the effective ID.
114.It Fl u
115Display the effective user ID as a number.
116.El
117.Sh EXIT STATUS
118.Ex -std id
119.Sh SEE ALSO
120.Xr who 1
121.Sh STANDARDS
122The
123.Nm
124utility is compliant with the
125.St -p1003.1-2008
126specification.
127.Pp
128The flag
129.Op Fl p
130is an extension to that specification.
131.Sh HISTORY
132The
133historic
134.Xr groups 1
135command is equivalent to
136.Ic id Fl Gn Op Ar user .
137.Pp
138The
139historic
140.Xr whoami 1
141command is equivalent to
142.Ic id Fl un .
143.Pp
144The
145.Nm
146command first appeared in
147.Bx 4.4 .
148