Deleted Added
full compact
su.1 (162286) su.1 (162792)
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
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: head/usr.bin/su/su.1 162286 2006-09-13 17:46:20Z joel $
33.\" $FreeBSD: head/usr.bin/su/su.1 162792 2006-09-29 15:20:48Z ru $
34.\"
35.Dd September 13, 2006
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
44.Op Fl flms
45.Op Fl c Ar class
46.Op Ar login Op Ar args
47.Sh DESCRIPTION
48The
49.Nm
50utility requests appropriate user credentials via PAM
51and switches to that user ID
52(the default user is the superuser).
53A shell is then executed.
54.Pp
55PAM is used to set the policy
56.Xr su 1
57will use.
58In particular, by default only users in the
59.Dq Li wheel
60group can switch to UID 0
61.Pq Dq Li root .
34.\"
35.Dd September 13, 2006
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
44.Op Fl flms
45.Op Fl c Ar class
46.Op Ar login Op Ar args
47.Sh DESCRIPTION
48The
49.Nm
50utility requests appropriate user credentials via PAM
51and switches to that user ID
52(the default user is the superuser).
53A shell is then executed.
54.Pp
55PAM is used to set the policy
56.Xr su 1
57will use.
58In particular, by default only users in the
59.Dq Li wheel
60group can switch to UID 0
61.Pq Dq Li root .
62This group requirement may be changed by modifying the
62This group requirement may be changed by modifying the
63.Dq Li pam_group
63.Dq Li pam_group
64section of
64section of
65.Pa /etc/pam.d/su .
65.Pa /etc/pam.d/su .
66See
66See
67.Xr pam_group 8
68for details on how to modify this setting.
69.Pp
70By default, the environment is unmodified with the exception of
71.Ev USER ,
72.Ev HOME ,
73and
74.Ev SHELL .
75.Ev HOME
76and
77.Ev SHELL
78are set to the target login's default values.
79.Ev USER
80is set to the target login, unless the target login has a user ID of 0,
81in which case it is unmodified.
82The invoked shell is the one belonging to the target login.
83This is the traditional behavior of
84.Nm .
85Resource limits and session priority applicable to the original user's
86login class (see
87.Xr login.conf 5 )
88are also normally retained unless the target login has a user ID of 0.
89.Pp
90The options are as follows:
91.Bl -tag -width Ds
92.It Fl f
93If the invoked shell is
94.Xr csh 1 ,
95this option prevents it from reading the
96.Dq Pa .cshrc
97file.
98.It Fl l
99Simulate a full login.
100The environment is discarded except for
101.Ev HOME ,
102.Ev SHELL ,
103.Ev PATH ,
104.Ev TERM ,
105and
106.Ev USER .
107.Ev HOME
108and
109.Ev SHELL
110are modified as above.
111.Ev USER
112is set to the target login.
113.Ev PATH
114is set to
115.Dq Pa /bin:/usr/bin .
116.Ev TERM
117is imported from your current environment.
118Environment variables may be set or overridden from the login class
119capabilities database according to the class of the target login.
120The invoked shell is the target login's, and
121.Nm
122will change directory to the target login's home directory.
123Resource limits and session priority are modified to that for the
124target account's login class.
125.It Fl
126(no letter) The same as
127.Fl l .
128.It Fl m
129Leave the environment unmodified.
130The invoked shell is your login shell, and no directory changes are made.
131As a security precaution, if the target user's shell is a non-standard
132shell (as defined by
133.Xr getusershell 3 )
134and the caller's real uid is
135non-zero,
136.Nm
137will fail.
138.It Fl s
139Set the MAC label to the user's default label as part of the user
140credential setup.
141Setting the MAC label may fail if the MAC label of the invoking process
142is not sufficient to transition to the user's default MAC label.
143If the label cannot be set,
144.Nm
145will fail.
146.It Fl c Ar class
147Use the settings of the specified login class.
148Only allowed for the super-user.
149.El
150.Pp
151The
152.Fl l
153(or
154.Fl )
155and
156.Fl m
157options are mutually exclusive; the last one specified
158overrides any previous ones.
159.Pp
160If the optional
161.Ar args
162are provided on the command line, they are passed to the login shell of
163the target login.
164Note that all command line arguments before the target login name are
165processed by
166.Nm
167itself, everything after the target login name gets passed to the login
168shell.
169.Pp
170By default (unless the prompt is reset by a startup file) the super-user
171prompt is set to
172.Dq Sy \&#
173to remind one of its awesome power.
174.Sh ENVIRONMENT
175Environment variables used by
176.Nm :
177.Bl -tag -width HOME
178.It Ev HOME
179Default home directory of real user ID unless modified as
180specified above.
181.It Ev PATH
182Default search path of real user ID unless modified as specified above.
183.It Ev TERM
184Provides terminal type which may be retained for the substituted
185user ID.
186.It Ev USER
187The user ID is always the effective ID (the target user ID) after an
188.Nm
189unless the user ID is 0 (root).
190.El
191.Sh FILES
192.Bl -tag -width ".Pa /etc/pam.d/su" -compact
193.It Pa /etc/pam.d/su
194PAM configuration for
195.Nm .
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 consists of more than a
207single word and hence is quoted for use with the
208.Fl c
209option being passed to the shell.
210(Most shells expect the argument to
211.Fl c
212to be a single word).
213.It Li "su -c staff man -c 'catman /usr/share/man /usr/local/man /usr/X11R6/man'"
214Same as above, but the target command is run with the resource limits of
215the login class
216.Dq staff .
217Note: in this example, the first
218.Fl c
219option applies to
220.Nm
221while the second is an argument to the shell being invoked.
222.It Li "su -l foo"
223Simulate a login for user foo.
224.It Li "su - foo"
225Same as above.
226.It Li "su -"
227Simulate a login for root.
228.El
229.Sh SEE ALSO
230.Xr csh 1 ,
231.Xr sh 1 ,
232.Xr group 5 ,
233.Xr login.conf 5 ,
234.Xr passwd 5 ,
235.Xr environ 7 ,
236.Xr pam_group 8
237.Sh HISTORY
238A
239.Nm
240command appeared in
241.At v1 .
67.Xr pam_group 8
68for details on how to modify this setting.
69.Pp
70By default, the environment is unmodified with the exception of
71.Ev USER ,
72.Ev HOME ,
73and
74.Ev SHELL .
75.Ev HOME
76and
77.Ev SHELL
78are set to the target login's default values.
79.Ev USER
80is set to the target login, unless the target login has a user ID of 0,
81in which case it is unmodified.
82The invoked shell is the one belonging to the target login.
83This is the traditional behavior of
84.Nm .
85Resource limits and session priority applicable to the original user's
86login class (see
87.Xr login.conf 5 )
88are also normally retained unless the target login has a user ID of 0.
89.Pp
90The options are as follows:
91.Bl -tag -width Ds
92.It Fl f
93If the invoked shell is
94.Xr csh 1 ,
95this option prevents it from reading the
96.Dq Pa .cshrc
97file.
98.It Fl l
99Simulate a full login.
100The environment is discarded except for
101.Ev HOME ,
102.Ev SHELL ,
103.Ev PATH ,
104.Ev TERM ,
105and
106.Ev USER .
107.Ev HOME
108and
109.Ev SHELL
110are modified as above.
111.Ev USER
112is set to the target login.
113.Ev PATH
114is set to
115.Dq Pa /bin:/usr/bin .
116.Ev TERM
117is imported from your current environment.
118Environment variables may be set or overridden from the login class
119capabilities database according to the class of the target login.
120The invoked shell is the target login's, and
121.Nm
122will change directory to the target login's home directory.
123Resource limits and session priority are modified to that for the
124target account's login class.
125.It Fl
126(no letter) The same as
127.Fl l .
128.It Fl m
129Leave the environment unmodified.
130The invoked shell is your login shell, and no directory changes are made.
131As a security precaution, if the target user's shell is a non-standard
132shell (as defined by
133.Xr getusershell 3 )
134and the caller's real uid is
135non-zero,
136.Nm
137will fail.
138.It Fl s
139Set the MAC label to the user's default label as part of the user
140credential setup.
141Setting the MAC label may fail if the MAC label of the invoking process
142is not sufficient to transition to the user's default MAC label.
143If the label cannot be set,
144.Nm
145will fail.
146.It Fl c Ar class
147Use the settings of the specified login class.
148Only allowed for the super-user.
149.El
150.Pp
151The
152.Fl l
153(or
154.Fl )
155and
156.Fl m
157options are mutually exclusive; the last one specified
158overrides any previous ones.
159.Pp
160If the optional
161.Ar args
162are provided on the command line, they are passed to the login shell of
163the target login.
164Note that all command line arguments before the target login name are
165processed by
166.Nm
167itself, everything after the target login name gets passed to the login
168shell.
169.Pp
170By default (unless the prompt is reset by a startup file) the super-user
171prompt is set to
172.Dq Sy \&#
173to remind one of its awesome power.
174.Sh ENVIRONMENT
175Environment variables used by
176.Nm :
177.Bl -tag -width HOME
178.It Ev HOME
179Default home directory of real user ID unless modified as
180specified above.
181.It Ev PATH
182Default search path of real user ID unless modified as specified above.
183.It Ev TERM
184Provides terminal type which may be retained for the substituted
185user ID.
186.It Ev USER
187The user ID is always the effective ID (the target user ID) after an
188.Nm
189unless the user ID is 0 (root).
190.El
191.Sh FILES
192.Bl -tag -width ".Pa /etc/pam.d/su" -compact
193.It Pa /etc/pam.d/su
194PAM configuration for
195.Nm .
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 consists of more than a
207single word and hence is quoted for use with the
208.Fl c
209option being passed to the shell.
210(Most shells expect the argument to
211.Fl c
212to be a single word).
213.It Li "su -c staff man -c 'catman /usr/share/man /usr/local/man /usr/X11R6/man'"
214Same as above, but the target command is run with the resource limits of
215the login class
216.Dq staff .
217Note: in this example, the first
218.Fl c
219option applies to
220.Nm
221while the second is an argument to the shell being invoked.
222.It Li "su -l foo"
223Simulate a login for user foo.
224.It Li "su - foo"
225Same as above.
226.It Li "su -"
227Simulate a login for root.
228.El
229.Sh SEE ALSO
230.Xr csh 1 ,
231.Xr sh 1 ,
232.Xr group 5 ,
233.Xr login.conf 5 ,
234.Xr passwd 5 ,
235.Xr environ 7 ,
236.Xr pam_group 8
237.Sh HISTORY
238A
239.Nm
240command appeared in
241.At v1 .