Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.bin / su / su.1
1 .\" Copyright (c) 1988, 1990, 1993, 1994
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)su.1        8.2 (Berkeley) 4/18/94
33 .\" $FreeBSD: src/usr.bin/su/su.1,v 1.17.2.6 2002/06/21 15:29:18 charnier Exp $
34 .\"
35 .Dd April 18, 1994
36 .Dt SU 1
37 .Os
38 .Sh NAME
39 .Nm su
40 .Nd substitute user identity
41 .Sh SYNOPSIS
42 .Nm
43 .Op Fl
44 .Op Fl Kflm
45 .Op Fl c Ar class
46 .Op Ar login Op Ar args
47 .Sh DESCRIPTION
48 The
49 .Nm
50 utility requests the Kerberos password for
51 .Ar login
52 (or for
53 .Dq Ar login Ns .root ,
54 if no login is provided), and switches to
55 that user and group ID after obtaining a Kerberos ticket granting ticket.
56 A shell is then executed.
57 The
58 .Nm
59 utility will resort to the local password file to find the password for
60 .Ar login
61 if there is a Kerberos error.
62 If
63 .Nm
64 is executed by root, no password is requested and a shell
65 with the appropriate user ID is executed; no additional Kerberos tickets
66 are obtained.
67 .Pp
68 By default, the environment is unmodified with the exception of
69 .Ev USER ,
70 .Ev HOME ,
71 and
72 .Ev SHELL .
73 .Ev HOME
74 and
75 .Ev SHELL
76 are set to the target login's default values.
77 .Ev USER
78 is set to the target login, unless the target login has a user ID of 0,
79 in which case it is unmodified.
80 The invoked shell is the target login's.
81 This is the traditional behavior of
82 .Nm .
83 Resource limits and session priority applicable to the original user's
84 login class (See
85 .Xr login.conf 5 )
86 are also normally retained unless the target login has a user ID of 0.
87 .Pp
88 The options are as follows:
89 .Bl -tag -width Ds
90 .It Fl K
91 Do not attempt to use Kerberos to authenticate the user.
92 .It Fl f
93 If the invoked shell is
94 .Xr csh 1 ,
95 this option prevents it from reading the
96 .Dq Pa .cshrc
97 file.
98 .It Fl l
99 Simulate a full login.
100 The environment is discarded except for
101 .Ev HOME ,
102 .Ev SHELL ,
103 .Ev PATH ,
104 .Ev TERM ,
105 and
106 .Ev USER .
107 .Ev HOME
108 and
109 .Ev SHELL
110 are modified as above.
111 .Ev USER
112 is set to the target login.
113 .Ev PATH
114 is set to
115 .Dq Pa /bin:/usr/bin .
116 .Ev TERM
117 is imported from your current environment.
118 Environment variables may be set or overridden from the login class
119 capabilities database according to the class of the target login.
120 The invoked shell is the target login's, and
121 .Nm
122 will change directory to the target login's home directory.
123 Resource limits and session priority are modified to that for the
124 target account's login class.
125 .It Fl
126 (no letter) The same as
127 .Fl l .
128 .It Fl m
129 Leave the environment unmodified.
130 The invoked shell is your login shell, and no directory changes are made.
131 As a security precaution, if the target user's shell is a non-standard
132 shell (as defined by
133 .Xr getusershell 3 )
134 and the caller's real uid is
135 non-zero,
136 .Nm
137 will fail.
138 .It Fl c Ar class
139 Use the settings of the specified login class.
140 Only allowed for the super-user.
141 .El
142 .Pp
143 The
144 .Fl l
145 (or
146 .Fl )
147 and
148 .Fl m
149 options are mutually exclusive; the last one specified
150 overrides any previous ones.
151 .Pp
152 If the optional
153 .Ar args
154 are provided on the command line, they are passed to the login shell of
155 the target login.
156 .Pp
157 Only users who are a member of group 0 (normally
158 .Dq wheel )
159 can
160 .Nm
161 to
162 .Dq root .
163 \ If group 0 is missing or empty, any user can
164 .Nm
165 to
166 .Dq root .
167 .Pp
168 By default (unless the prompt is reset by a startup file) the super-user
169 prompt is set to
170 .Dq Sy \&#
171 to remind one of its awesome power.
172 .Sh FILES
173 .Bl -tag -width /etc/auth.conf -compact
174 .It Pa /etc/auth.conf
175 configure authentication services
176 .El
177 .Sh SEE ALSO
178 .Xr csh 1 ,
179 .Xr kerberos 1 ,
180 .Xr kinit 1 ,
181 .Xr login 1 ,
182 .Xr sh 1 ,
183 .Xr group 5 ,
184 .Xr login.conf 5 ,
185 .Xr passwd 5 ,
186 .Xr environ 7
187 .Sh ENVIRONMENT
188 Environment variables used by
189 .Nm :
190 .Bl -tag -width HOME
191 .It Ev HOME
192 Default home directory of real user ID unless modified as
193 specified above.
194 .It Ev PATH
195 Default search path of real user ID unless modified as specified above.
196 .It Ev TERM
197 Provides terminal type which may be retained for the substituted
198 user ID.
199 .It Ev USER
200 The user ID is always the effective ID (the target user ID) after an
201 .Nm
202 unless the user ID is 0 (root).
203 .El
204 .Sh EXAMPLES
205 .Bl -tag -width 5n -compact
206 .It Li "su man -c catman"
207 Runs the command
208 .Li catman
209 as user
210 .Li man .
211 You will be asked for man's password unless your real UID is 0.
212 .It Li "su man -c 'catman /usr/share/man /usr/local/man /usr/X11R6/man'"
213 Same as above, but the target command consists of more than a
214 single word and hence is quoted for use with the
215 .Fl c
216 option being passed to the shell.  (Most shells expect the argument to
217 .Fl c
218 to be a single word).
219 .It Li "su -c staff man -c 'catman /usr/share/man /usr/local/man /usr/X11R6/man'"
220 Same as above, but the target command is run with the resource limits of
221 the login class
222 .Dq staff .
223 Note: in this example, the first
224 .Fl c
225 option applies to
226 .Nm
227 while the second is an argument to the shell being invoked.
228 .It Li "su -l foo"
229 Simulate a login for user foo.
230 .It Li "su - foo"
231 Same as above.
232 .It Li "su -  "
233 Simulate a login for root.
234 .El
235 .Sh HISTORY
236 A
237 .Nm
238 command appeared in
239 .At v1 .