Merge branch 'vendor/ZLIB'
[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 .\" 4. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)su.1        8.2 (Berkeley) 4/18/94
29 .\" $FreeBSD: src/usr.bin/su/su.1,v 1.41 2008/07/01 20:56:23 danger Exp $
30 .\" $DragonFly: src/usr.bin/su/su.1,v 1.6 2007/03/25 11:35:11 swildner Exp $
31 .\"
32 .Dd July 1, 2008
33 .Dt SU 1
34 .Os
35 .Sh NAME
36 .Nm su
37 .Nd substitute user identity
38 .Sh SYNOPSIS
39 .Nm
40 .Op Fl
41 .Op Fl flm
42 .Op Fl c Ar class
43 .Op Ar login Op Ar args
44 .Sh DESCRIPTION
45 The
46 .Nm
47 utility requests appropriate user credentials via PAM
48 and switches to that user ID
49 (the default user is the superuser).
50 A shell is then executed.
51 .Pp
52 PAM is used to set the policy
53 .Xr su 1
54 will use.
55 In particular, by default only users in the
56 .Dq Li wheel
57 group can switch to UID 0
58 .Pq Dq Li root .
59 This group requirement may be changed by modifying the
60 .Dq Li pam_group
61 section of
62 .Pa /etc/pam.d/su .
63 See
64 .Xr pam_group 8
65 for details on how to modify this setting.
66 .Pp
67 By default, the environment is unmodified with the exception of
68 .Ev USER ,
69 .Ev HOME ,
70 and
71 .Ev SHELL .
72 .Ev HOME
73 and
74 .Ev SHELL
75 are set to the target login's default values.
76 .Ev USER
77 is set to the target login, unless the target login has a user ID of 0,
78 in which case it is unmodified.
79 The invoked shell is the one belonging to the target login.
80 This is the traditional behavior of
81 .Nm .
82 Resource limits and session priority applicable to the original user's
83 login class (see
84 .Xr login.conf 5 )
85 are also normally retained unless the target login has a user ID of 0.
86 .Pp
87 The options are as follows:
88 .Bl -tag -width Ds
89 .It Fl f
90 If the invoked shell is
91 .Xr csh 1 ,
92 this option prevents it from reading the
93 .Dq Pa .cshrc
94 file.
95 .It Fl l
96 Simulate a full login.
97 The environment is discarded except for
98 .Ev HOME ,
99 .Ev SHELL ,
100 .Ev PATH ,
101 .Ev TERM ,
102 and
103 .Ev USER .
104 .Ev HOME
105 and
106 .Ev SHELL
107 are modified as above.
108 .Ev USER
109 is set to the target login.
110 .Ev PATH
111 is set to
112 .Dq Pa /bin:/usr/bin .
113 .Ev TERM
114 is imported from your current environment.
115 Environment variables may be set or overridden from the login class
116 capabilities database according to the class of the target login.
117 The invoked shell is the target login's, and
118 .Nm
119 will change directory to the target login's home directory.
120 Resource limits and session priority are modified to that for the
121 target account's login class.
122 .It Fl
123 (no letter) The same as
124 .Fl l .
125 .It Fl m
126 Leave the environment unmodified.
127 The invoked shell is your login shell, and no directory changes are made.
128 As a security precaution, if the target user's shell is a non-standard
129 shell (as defined by
130 .Xr getusershell 3 )
131 and the caller's real uid is
132 non-zero,
133 .Nm
134 will fail.
135 .It Fl c Ar class
136 Use the settings of the specified login class.
137 Only allowed for the super-user.
138 .El
139 .Pp
140 The
141 .Fl l
142 (or
143 .Fl )
144 and
145 .Fl m
146 options are mutually exclusive; the last one specified
147 overrides any previous ones.
148 .Pp
149 If the optional
150 .Ar args
151 are provided on the command line, they are passed to the login shell of
152 the target login.
153 Note that all command line arguments before the target login name are
154 processed by
155 .Nm
156 itself, everything after the target login name gets passed to the login
157 shell.
158 .Pp
159 By default (unless the prompt is reset by a startup file) the super-user
160 prompt is set to
161 .Dq Sy \&#
162 to remind one of its awesome power.
163 .Sh ENVIRONMENT
164 Environment variables used by
165 .Nm :
166 .Bl -tag -width HOME
167 .It Ev HOME
168 Default home directory of real user ID unless modified as
169 specified above.
170 .It Ev PATH
171 Default search path of real user ID unless modified as specified above.
172 .It Ev TERM
173 Provides terminal type which may be retained for the substituted
174 user ID.
175 .It Ev USER
176 The user ID is always the effective ID (the target user ID) after an
177 .Nm
178 unless the user ID is 0 (root).
179 .El
180 .Sh FILES
181 .Bl -tag -width ".Pa /etc/pam.d/su" -compact
182 .It Pa /etc/pam.d/su
183 PAM configuration for
184 .Nm .
185 .El
186 .Sh EXAMPLES
187 .Bl -tag -width 5n -compact
188 .It Li "su -m man -c catman"
189 Runs the command
190 .Li catman
191 as user
192 .Li man .
193 You will be asked for man's password unless your real UID is 0.
194 Note that the
195 .Fl m
196 option is required since user
197 .Dq man
198 does not have a valid shell by default.
199 .It Li "su -m man -c 'catman /usr/share/man /usr/local/man /usr/pkg/xorg/man'"
200 Same as above, but the target command consists of more than a
201 single word and hence is quoted for use with the
202 .Fl c
203 option being passed to the shell.
204 (Most shells expect the argument to
205 .Fl c
206 to be a single word).
207 .It Li "su -m -c staff man -c 'catman /usr/share/man /usr/local/man /usr/pkg/xorg/man'"
208 Same as above, but the target command is run with the resource limits of
209 the login class
210 .Dq staff .
211 Note: in this example, the first
212 .Fl c
213 option applies to
214 .Nm
215 while the second is an argument to the shell being invoked.
216 .It Li "su -l foo"
217 Simulate a login for user foo.
218 .It Li "su - foo"
219 Same as above.
220 .It Li "su -"
221 Simulate a login for root.
222 .El
223 .Sh SEE ALSO
224 .Xr csh 1 ,
225 .Xr sh 1 ,
226 .Xr group 5 ,
227 .Xr login.conf 5 ,
228 .Xr passwd 5 ,
229 .Xr environ 7 ,
230 .Xr pam_group 8
231 .Sh HISTORY
232 A
233 .Nm
234 command appeared in
235 .At v1 .