Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ su(1M) — SunOS 5.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

env(1)

login(1)

sh(1)

passwd(4)

profile(4)

environ(5)

su(1M)

NAME

su − become super-user or another user

SYNOPSIS

su [ − ] [ username [ arg ... ] ]

AVAILABILITY

SUNWcsr

DESCRIPTION

su allows one to become another user without logging off.  The default user name is root (super-user). 

To use su, the appropriate password must be supplied (unless one is already root).  If the password is correct, su creates a new shell process that has the real and effective user ID, group IDs, and supplementary group list set to those of the specified username.  The new shell will be the shell specified in the shell field of username’s password file entry (see passwd(4)).  If no shell is specified, /usr/bin/sh is used.  (See sh(1)).  To return to normal user ID privileges, type an EOF character (CTRL-d) to exit the new shell. 

Any additional arguments given on the command line are passed to the new shell.  When using programs such as sh, an arg of the form −c string executes string using the shell and an arg of −r gives the user a restricted shell. 

The following statements are true only if the optional program named in the shell field of the specified user’s password file entry is like sh.  If the first argument to su is a −, the environment will be changed to what would be expected if the user actually logged in as the specified user.  This is done by invoking the program used as the shell with an arg0 value whose first character is −, thus causing first the system’s profile (/etc/profile) and then the specified user’s profile (.profile in the new HOME directory) to be executed.  Otherwise, the environment is passed along with the possible exception of $PATH, which is set to /sbin:/usr/sbin:/usr/bin:/etc for root.  Note that if the optional program used as the shell is /usr/bin/sh, the user’s .profile can check arg0 for −sh or −su to determine if it was invoked by login or su, respectively.  If the user’s program is other than /usr/bin/sh, then .profile is invoked with an arg0 of −program by both login and su. 

All attempts to become another user using su are logged in the log file /var/adm/sulog. 

EXAMPLES

To become user bin while retaining your previously exported environment, execute:

example% su bin

To become user bin but change the environment to what would be expected if bin had originally logged in, execute:

example% su − bin

To execute command with the temporary environment and permissions of user bin, type:

example% su − bin −c "command args"

ENVIRONMENT

If any of the LC_∗ variables ( LC_CTYPE, LC_MESSAGES, LC_TIME, LC_COLLATE, LC_NUMERIC, and LC_MONETARY ) (see environ(5)) are not set in the environment, the operational behavior of su for each corresponding locale category is determined by the value of the LANG environment variable.  If LC_ALL is set, its contents are used to override both the LANG and the other LC_∗ variables.  If none of the above variables are set in the environment, the "C"  (U.S. style) locale determines how su behaves. 

LC_CTYPE
Determines how su handles characters. When LC_CTYPE is set to a valid value, su can display and handle text and filenames containing valid characters for that locale.  su can display and handle Extended Unix Code (EUC) characters where any individual character can be 1, 2, or 3 bytes wide.  su can also handle EUC characters of 1, 2, or more column widths. In the "C" locale, only characters from ISO 8859-1 are valid. 

LC_MESSAGES
Determines how diagnostic and informative messages are presented. This includes the language and style of the messages, and the correct form of affirmative and negative responses.  In the "C" locale, the messages are presented in the default form found in the program itself (in most cases, U.S. English).

FILES

/etc/passwdsystem’s password file
/etc/profilesystem’s profile
$HOME/.profileuser’s profile
/var/adm/suloglog file
/etc/default/suthe default parameters that live here are:

SULOG:
If defined, all attempts to su to
another user are logged in the indicated file.

CONSOLE:
If defined, all attempts to suroot
are logged on the console.

PATH:
Default path.

SUPATH:
Default path for a user invoking suroot.

SEE ALSO

env(1), login(1), sh(1), passwd(4), profile(4), environ(5)

SunOS 5.2  —  Last change: 14 Sep 1992

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026