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