xref: /freebsd/usr.bin/su/su.1 (revision 8e537d168674d6b65869f73c20813001af875738)
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.\"	$Id$
34.\"
35.\" this is for hilit19's braindeadness: "
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 su
44.Op Fl Kflm
45.Op Ar login Op Ar args
46.Sh DESCRIPTION
47.Nm Su
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.
55.Nm Su
56will resort to the local password file to find the password for
57.Ar login
58if there is a Kerberos error.
59If
60.Nm su
61is executed by root, no password is requested and a shell
62with the appropriate user ID is executed; no additional Kerberos tickets
63are obtained.
64.Pp
65By default, the environment is unmodified with the exception of
66.Ev USER ,
67.Ev HOME ,
68and
69.Ev SHELL .
70.Ev HOME
71and
72.Ev SHELL
73are set to the target login's default values.
74.Ev USER
75is set to the target login, unless the target login has a user ID of 0,
76in which case it is unmodified.
77The invoked shell is the target login's.
78This is the traditional behavior of
79.Nm su .
80.Pp
81The options are as follows:
82.Bl -tag -width Ds
83.It Fl K
84Do not attempt to use Kerberos to authenticate the user.
85.It Fl f
86If the invoked shell is
87.Xr csh 1 ,
88this option prevents it from reading the
89.Dq Pa .cshrc
90file.
91.It Fl l
92Simulate a full login.
93The environment is discarded except for
94.Ev HOME ,
95.Ev SHELL ,
96.Ev PATH ,
97.Ev TERM ,
98and
99.Ev USER .
100.Ev HOME
101and
102.Ev SHELL
103are modified as above.
104.Ev USER
105is set to the target login.
106.Ev PATH
107is set to
108.Dq Pa /bin:/usr/bin .
109.Ev TERM
110is imported from your current environment.
111The invoked shell is the target login's, and
112.Nm su
113will change directory to the target login's home directory.
114.It Fl m
115Leave the environment unmodified.
116The invoked shell is your login shell, and no directory changes are made.
117As a security precaution, if the target user's shell is a non-standard
118shell (as defined by
119.Xr getusershell 3 )
120and the caller's real uid is
121non-zero,
122.Nm su
123will fail.
124.El
125.Pp
126The
127.Fl l
128and
129.Fl m
130options are mutually exclusive; the last one specified
131overrides any previous ones.
132.Pp
133If the optional
134.Ar args
135are provided on the command line, they are passed to the login shell of
136the target login.  This allows it to pass arbitrary commands via
137the
138.Fl c
139option as understood by most shells.  Note that
140.Fl c
141usually expects a single argument only; you have to quote it when
142passing multiple words.
143.Pp
144Only users in group 0 (normally
145.Dq wheel )
146can
147.Nm su
148to
149.Dq root .
150.Pp
151By default (unless the prompt is reset by a startup file) the super-user
152prompt is set to
153.Dq Sy \&#
154to remind one of its awesome power.
155.Sh SEE ALSO
156.Xr csh 1 ,
157.Xr login 1 ,
158.Xr sh 1 ,
159.Xr kinit 1 ,
160.Xr kerberos 1 ,
161.Xr passwd 5 ,
162.Xr group 5 ,
163.Xr environ 7
164.Sh ENVIRONMENT
165Environment variables used by
166.Nm su :
167.Bl -tag -width HOME
168.It Ev HOME
169Default home directory of real user ID unless modified as
170specified above.
171.It Ev PATH
172Default search path of real user ID unless modified as specified above.
173.It Ev TERM
174Provides terminal type which may be retained for the substituted
175user ID.
176.It Ev USER
177The user ID is always the effective ID (the target user ID) after an
178.Nm su
179unless the user ID is 0 (root).
180.El
181.Sh EXAMPLES
182.Bl -tag -width 5n -compact
183.It Li "su man -c catman"
184Runs the command
185.Li catman
186as user
187.Li man .
188You will be asked for man's password unless your real UID is 0.
189.It Li "su man -c 'catman /usr/share/man /usr/local/man /usr/X11R6/man'"
190Same as above, but the target command constitutes of more than a
191single word.
192.It Li "su -l foo"
193Pretend a login for user
194.Li foo .
195.El
196.Sh HISTORY
197A
198.Nm
199command appeared in
200.At v1 .
201