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