2 .\" Copyright 1989 AT&T
3 .\" Copyright (C) 2004, Sun Microsystems, Inc.
4 .\" All Rights Reserved.
5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
7 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
8 .TH SU 1M "Feb 26, 2004"
10 su \- become superuser or another user
14 \fBsu\fR [\fB-\fR] [\fIusername\fR [arg...]]
20 The \fBsu\fR command allows one to become another user without logging off or
21 to assume a role. The default user \fIname\fR is \fBroot\fR (superuser).
24 To use \fBsu\fR, the appropriate password must be supplied (unless the invoker
25 is already \fBroot\fR). If the password is correct, \fBsu\fR creates a new
26 shell process that has the real and effective user \fBID,\fR group \fBIDs,\fR
27 and supplementary group list set to those of the specified \fIusername\fR.
28 Additionally, the new shell's project ID is set to the default project ID of
29 the specified user. See \fBgetdefaultproj\fR(3PROJECT),
30 \fBsetproject\fR(3PROJECT). The new shell will be the shell specified in the
31 shell field of \fIusername\fR's password file entry (see \fBpasswd\fR(4)). If
32 no shell is specified, \fB/usr/bin/sh\fR is used (see \fBsh\fR(1)). If
33 superuser privilege is requested and the shell for the superuser cannot be
34 invoked using \fBexec\fR(2), \fB/sbin/sh\fR is used as a fallback. To return to
35 normal user \fBID\fR privileges, type an \fBEOF\fR character (CTRL-D) to exit
39 Any additional arguments given on the command line are passed to the new shell.
40 When using programs such as \fBsh\fR, an \fIarg\fR of the form \fB-c\fR\fI
41 string\fR executes \fIstring\fR using the shell and an \fIarg\fR of \fB-r\fR
42 gives the user a restricted shell.
45 To create a login environment, the command \fB"su -"\fR does the following:
50 In addition to what is already propagated, the \fBLC*\fR and \fBLANG\fR
51 environment variables from the specified user's environment are also
58 Propagate \fBTZ\fR from the user's environment. If \fBTZ\fR is not found in the
59 user's environment, \fBsu\fR uses the \fBTZ\fR value from the \fBTIMEZONE\fR
60 parameter found in \fB/etc/default/login\fR.
66 Set \fBMAIL\fR to \fB/var/mail/\fInew_user\fR\fR.
70 If the first argument to \fBsu\fR is a dash (-), the environment will be
71 changed to what would be expected if the user actually logged in as the
72 specified user. Otherwise, the environment is passed along, with the exception
73 of \fB$\fR\fBPATH\fR\fB, \fR which is controlled by \fBPATH\fR and
74 \fBSU\fR\fBPATH\fR in \fB/etc/default/su\fR.
77 All attempts to become another user using \fBsu\fR are logged in the log file
78 \fB/var/adm/sulog\fR (see \fBsulog\fR(4)).
82 \fBsu\fR uses \fBpam\fR(3PAM) with the service name \fBsu\fR for
83 authentication, account management, and credential establishment.
86 \fBExample 1 \fRBecoming User \fBbin\fR While Retaining Your Previously
90 To become user \fBbin\fR while retaining your previously exported environment,
102 \fBExample 2 \fRBecoming User \fBbin\fR and Changing to \fBbin\fR's Login
106 To become user \fBbin\fR but change the environment to what would be expected
107 if \fBbin\fR had originally logged in, execute:
112 example% \fBsu - bin\fR
118 \fBExample 3 \fRExecuting command with user \fBbin\fR's Environment and
122 To execute command with the temporary environment and permissions of user
128 example% \fBsu - bin -c "\fIcommand args\fR"\fR
133 .SH ENVIRONMENT VARIABLES
136 Variables with \fBLD_\fR prefix are removed for security reasons. Thus, \fBsu
137 bin\fR will not retain previously exported variables with \fBLD_\fR prefix
138 while becoming user \fBbin\fR.
141 If any of the \fBLC_*\fR variables ( \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR,
142 \fBLC_TIME\fR, \fBLC_COLLATE\fR, \fBLC_NUMERIC\fR, and \fBLC_MONETARY\fR) (see
143 \fBenviron\fR(5)) are not set in the environment, the operational behavior of
144 \fBsu\fR for each corresponding locale category is determined by the value of
145 the \fBLANG\fR environment variable. If \fBLC_ALL\fR is set, its contents are
146 used to override both the \fBLANG\fR and the other \fBLC_*\fR variables. If
147 none of the above variables are set in the environment, the "C" (U.S. style)
148 locale determines how \fBsu\fR behaves.
155 Determines how \fBsu\fR handles characters. When \fBLC_CTYPE\fR is set to a
156 valid value, \fBsu\fR can display and handle text and filenames containing
157 valid characters for that locale. \fBsu\fR can display and handle Extended Unix
158 Code (\fBEUC\fR) characters where any individual character can be \fB1\fR,
159 \fB2\fR, or \fB3\fR bytes wide. \fBsu\fR can also handle \fBEUC\fR characters
160 of \fB1\fR, \fB2\fR, or more column widths. In the "C" locale, only characters
161 from ISO 8859-1 are valid.
167 \fB\fBLC_MESSAGES\fR\fR
170 Determines how diagnostic and informative messages are presented. This includes
171 the language and style of the messages, and the correct form of affirmative and
172 negative responses. In the "C" locale, the messages are presented in the
173 default form found in the program itself (in most cases, U.S. English).
180 \fB\fB$\fR\fBHOME\fR\fB/.profile\fR\fR
183 user's login commands for \fBsh\fR and \fBksh\fR
189 \fB\fB/etc/passwd\fR\fR
192 system's password file
198 \fB\fB/etc/profile\fR\fR
201 system-wide \fBsh\fR and \fBksh\fR login commands
207 \fB\fB/var/adm/sulog\fR\fR
216 \fB\fB/etc/default/su\fR\fR
219 the default parameters in this file are:
226 If defined, all attempts to \fBsu\fR to another user are logged in the
236 If defined, all attempts to \fBsu\fR to \fBroot\fR are logged on the console.
245 Default path. (\fB/usr/bin:\fR)
251 \fB\fBSU\fR\fBPATH\fR\fR
254 Default path for a user invoking \fBsu\fR to \fBroot\fR.
255 (\fB/usr/sbin:/usr/bin\fR)
264 Determines whether the \fBsyslog\fR(3C) \fBLOG_AUTH\fR facility should be used
265 to log all \fBsu\fR attempts. \fBLOG_NOTICE\fR messages are generated for
266 \fBsu\fR's to root, \fBLOG_INFO\fR messages are generated for \fBsu\fR's to
267 other users, and \fBLOG_CRIT\fR messages are generated for failed \fBsu\fR
276 \fB\fB/etc/default/login\fR\fR
279 the default parameters in this file are:
286 Sets the TZ environment variable of the shell.
294 \fBcsh\fR(1), \fBenv\fR(1), \fBksh\fR(1), \fBlogin\fR(1), \fBroles\fR(1),
295 \fBsh\fR(1), \fBsyslogd\fR(1M), \fBexec\fR(2), \fBgetdefaultproj\fR(3PROJECT),
296 \fBsetproject\fR(3PROJECT), \fBpam\fR(3PAM), \fBpam_authenticate\fR(3PAM),
297 \fBpam_acct_mgmt\fR(3PAM), \fBpam_setcred\fR(3PAM), \fBpam.conf\fR(4),
298 \fBpasswd\fR(4), \fBprofile\fR(4), \fBsulog\fR(4), \fBsyslog\fR(3C),
299 \fBattributes\fR(5), \fBenviron\fR(5)