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