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