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.\" $DragonFly: src/usr.bin/su/su.1,v 1.6 2007/03/25 11:35:11 swildner Exp $ 35.\" 36.Dd April 18, 1994 37.Dt SU 1 38.Os 39.Sh NAME 40.Nm su 41.Nd substitute user identity 42.Sh SYNOPSIS 43.Nm 44.Op Fl 45.Op Fl Kflm 46.Op Fl c Ar class 47.Op Ar login Op Ar args 48.Sh DESCRIPTION 49The 50.Nm 51utility requests the Kerberos password for 52.Ar login 53(or for 54.Dq Ar login Ns .root , 55if no login is provided), and switches to 56that user and group ID after obtaining a Kerberos ticket granting ticket. 57A shell is then executed. 58The 59.Nm 60utility will resort to the local password file to find the password for 61.Ar login 62if there is a Kerberos error. 63If 64.Nm 65is executed by root, no password is requested and a shell 66with the appropriate user ID is executed; no additional Kerberos tickets 67are obtained. 68.Pp 69By default, the environment is unmodified with the exception of 70.Ev USER , 71.Ev HOME , 72and 73.Ev SHELL . 74.Ev HOME 75and 76.Ev SHELL 77are set to the target login's default values. 78.Ev USER 79is set to the target login, unless the target login has a user ID of 0, 80in which case it is unmodified. 81The invoked shell is the target login's. 82This is the traditional behavior of 83.Nm . 84Resource limits and session priority applicable to the original user's 85login class (See 86.Xr login.conf 5 ) 87are also normally retained unless the target login has a user ID of 0. 88.Pp 89The options are as follows: 90.Bl -tag -width Ds 91.It Fl K 92Do not attempt to use Kerberos to authenticate the user. 93.It Fl f 94If the invoked shell is 95.Xr csh 1 , 96this option prevents it from reading the 97.Dq Pa .cshrc 98file. 99.It Fl l 100Simulate a full login. 101The environment is discarded except for 102.Ev HOME , 103.Ev SHELL , 104.Ev PATH , 105.Ev TERM , 106and 107.Ev USER . 108.Ev HOME 109and 110.Ev SHELL 111are modified as above. 112.Ev USER 113is set to the target login. 114.Ev PATH 115is set to 116.Dq Pa /bin:/usr/bin . 117.Ev TERM 118is imported from your current environment. 119Environment variables may be set or overridden from the login class 120capabilities database according to the class of the target login. 121The invoked shell is the target login's, and 122.Nm 123will change directory to the target login's home directory. 124Resource limits and session priority are modified to that for the 125target account's login class. 126.It Fl 127(no letter) The same as 128.Fl l . 129.It Fl m 130Leave the environment unmodified. 131The invoked shell is your login shell, and no directory changes are made. 132As a security precaution, if the target user's shell is a non-standard 133shell (as defined by 134.Xr getusershell 3 ) 135and the caller's real uid is 136non-zero, 137.Nm 138will fail. 139.It Fl c Ar class 140Use the settings of the specified login class. 141Only allowed for the super-user. 142.El 143.Pp 144The 145.Fl l 146(or 147.Fl ) 148and 149.Fl m 150options are mutually exclusive; the last one specified 151overrides any previous ones. 152.Pp 153If the optional 154.Ar args 155are provided on the command line, they are passed to the login shell of 156the target login. 157.Pp 158Only users who are a member of group 0 (normally 159.Dq wheel ) 160can 161.Nm 162to 163.Dq root . 164\ If group 0 is missing or empty, any user can 165.Nm 166to 167.Dq root . 168.Pp 169By default (unless the prompt is reset by a startup file) the super-user 170prompt is set to 171.Dq Sy \&# 172to remind one of its awesome power. 173.Sh ENVIRONMENT 174Environment variables used by 175.Nm : 176.Bl -tag -width HOME 177.It Ev HOME 178Default home directory of real user ID unless modified as 179specified above. 180.It Ev PATH 181Default search path of real user ID unless modified as specified above. 182.It Ev TERM 183Provides terminal type which may be retained for the substituted 184user ID. 185.It Ev USER 186The user ID is always the effective ID (the target user ID) after an 187.Nm 188unless the user ID is 0 (root). 189.El 190.Sh FILES 191.Bl -tag -width /etc/auth.conf -compact 192.It Pa /etc/auth.conf 193configure authentication services 194.El 195.Sh EXAMPLES 196.Bl -tag -width 5n -compact 197.It Li "su man -c catman" 198Runs the command 199.Li catman 200as user 201.Li man , 202assuming man's shell supports the 203.Fl c 204option. 205You will be asked for man's password unless your real UID is 0. 206.It Li "su -m man -c catman" 207Same as above, but use the shell and environment of the current 208user instead of those of man. 209This allows commands to be executed as user man even when man's shell is 210.Xr nologin 8 . 211.It Li "su -mf man -c catman" 212Same as above, but do not re-evaluate the current user's 213.Pa .cshrc 214either. 215.It Li "su -mf man -c 'catman /usr/share/man /usr/local/man /usr/pkg/xorg/man'" 216Same as above, but the target command consists of more than a 217single word and hence is quoted for use with the 218.Fl c 219option being passed to the shell. (Most shells expect the argument to 220.Fl c 221to be a single word). 222.It Li "su -mf -c staff man -c 'catman /usr/share/man /usr/local/man /usr/pkg/xorg/man'" 223Same as above, but the target command is run with the resource limits of 224the login class 225.Dq staff . 226Note: in this example, the first 227.Fl c 228option applies to 229.Nm 230while the second is an argument to the shell being invoked. 231.It Li "su -l foo" 232Simulate a login for user foo. 233.It Li "su - foo" 234Same as above. 235.It Li "su - " 236Simulate a login for root. 237.El 238.Sh SEE ALSO 239.Xr csh 1 , 240.Xr kinit 1 , 241.Xr login 1 , 242.Xr sh 1 , 243.Xr group 5 , 244.Xr login.conf 5 , 245.Xr passwd 5 , 246.Xr environ 7 , 247.Xr kerberos 8 , 248.Xr nologin 8 249.Sh HISTORY 250A 251.Nm 252command appeared in 253.At v1 . 254