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.\" from: @(#)su.1 8.2 (Berkeley) 4/18/94 33.\" $NetBSD: su.1,v 1.25 2002/10/13 00:55:17 wiz Exp $ 34.\" 35.Dd March 7, 2001 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 Kflm 44.Op Fl c Ar login-class 45.Op Ar login Op Ar "shell arguments" 46.Sh DESCRIPTION 47.Nm 48requests the Kerberos password for 49.Ar login 50(or for 51.Dq Ar login Ns .root , 52if no login is provided), and switches to 53that user and group ID after obtaining a Kerberos ticket granting ticket. 54A shell is then executed, and any additional 55.Ar "shell arguments" 56after the login name are passed to the shell. 57.Nm 58will resort to the local password file to find the password for 59.Ar login 60if there is a Kerberos error. 61If 62.Nm 63is executed by root, no password is requested and a shell 64with the appropriate user ID is executed; no additional Kerberos tickets 65are obtained. 66.Pp 67Alternatively, if the user enters the password "s/key", authentication 68will use the S/Key one-time password system as described in 69.Xr skey 1 . 70S/Key is a Trademark of Bellcore. 71.Pp 72By default, the environment is unmodified with the exception of 73.Ev USER , 74.Ev HOME , 75.Ev SHELL , 76and 77.Ev SU_FROM . 78.Ev HOME 79and 80.Ev SHELL 81are set to the target login's default values. 82.Ev USER 83is set to the target login, unless the target login has a user ID of 0, 84in which case it is unmodified. 85.Ev SU_FROM 86is set to the caller's login. 87The invoked shell is the target login's. 88With the exception of 89.Ev SU_FROM 90this is the traditional behavior of 91.Nm "" . 92.Pp 93The options are as follows: 94.Bl -tag -width Ds 95.It Fl K 96Do not attempt to use Kerberos to authenticate the user. 97.It Fl c 98Specify a login class. 99You may only override the default class if you're already root. 100See 101.Xr login.conf 5 102for details. 103.It Fl f 104If the invoked shell is 105.Xr csh 1 , 106this option prevents it from reading the 107.Dq Pa .cshrc 108file. 109.It Fl l 110Simulate a full login. 111The environment is discarded except for 112.Ev HOME , 113.Ev SHELL , 114.Ev PATH , 115.Ev TERM , 116.Ev USER , 117and 118.Ev SU_FROM . 119.Ev HOME 120.Ev SHELL , 121and 122.Ev SU_FROM 123are modified as above. 124.Ev USER 125is set to the target login. 126.Ev PATH 127is set to 128is set to the path specified in the 129.Pa /etc/login.conf 130file (or to the default of 131.Dq Pa /usr/bin:/bin:/usr/pkg/bin:/usr/local/bin 132). 133.Ev TERM 134is imported from your current environment. 135The invoked shell is the target login's, and 136.Nm 137will change directory to the target login's home directory. 138.It Fl 139Same as 140.Fl l 141.It Fl m 142Leave the environment unmodified. 143The invoked shell is your login shell, and no directory changes are made. 144As a security precaution, if the target user's shell is a non-standard 145shell (as defined by 146.Xr getusershell 3 ) 147and the caller's real uid is 148non-zero, 149.Nm 150will fail. 151.El 152.Pp 153The 154.Fl l 155and 156.Fl m 157options are mutually exclusive; the last one specified 158overrides any previous ones. 159.Pp 160Only users in group 161.Dq wheel 162(normally gid 0), 163as listed in 164.Pa /etc/group , 165can 166.Nm 167to 168.Dq root , 169unless group wheel does not exist or has no members. 170(If you do not want anybody to be able to 171.Nm 172to 173.Dq root , 174make 175.Dq root 176the only member of group 177.Dq wheel , 178which is the default.) 179.Pp 180For sites with very large user populations, group 181.Dq wheel 182can contain the names of other groups that will be considered authorized 183to 184.Nm 185to 186.Dq root . 187.Pp 188By default (unless the prompt is reset by a startup file) the super-user 189prompt is set to 190.Dq Sy \&# 191to remind one of its awesome power. 192.Sh ENVIRONMENT 193Environment variables used by 194.Nm "" : 195.Bl -tag -width "HOME" 196.It Ev HOME 197Default home directory of real user ID unless modified as 198specified above. 199.It Ev PATH 200Default search path of real user ID unless modified as specified above. 201.It Ev TERM 202Provides terminal type which may be retained for the substituted 203user ID. 204.It Ev USER 205The user ID is always the effective ID (the target user ID) after an 206.Nm 207unless the user ID is 0 (root). 208.El 209.Sh EXAMPLES 210To become user username and use the same environment as in original shell, execute: 211.Bd -literal -offset indent 212su username 213.Ed 214.Pp 215To become user username and use environment as if full login would be performed, 216execute: 217.Bd -literal -offset indent 218su -l username 219.Ed 220.Pp 221When a 222.Fl c 223option is included 224.Em after 225the 226.Ar login 227name it is not a 228.Nm 229option, because any arguments after the 230.Ar login 231are passed to the shell. 232(See 233.Xr csh 1 , 234.Xr ksh 1 235or 236.Xr sh 1 237for details.) 238To execute arbitrary command with privileges of user 239.Em username , 240execute: 241.Bd -literal -offset indent 242su username -c "command args" 243.Ed 244.Sh SEE ALSO 245.Xr csh 1 , 246.Xr kinit 1 , 247.Xr login 1 , 248.Xr sh 1 , 249.Xr skey 1 , 250.Xr setusercontext 3 , 251.Xr group 5 , 252.Xr login.conf 5 , 253.Xr passwd 5 , 254.Xr environ 7 , 255.Xr kerberos 8 256.Sh HISTORY 257A 258.Nm 259command existed in 260.At v5 261(and probably earlier). 262