Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

env(1)

login(1)

sh(1)

initgroups(3C)

group(4)

passwd(4)

profile(4)

environ(5)

su(1)

NAME

su − become super-user or another user

SYNOPSIS

su [-] [name [arg ...]]

DESCRIPTION

su allows one to become another user without logging out.  The default user name is root (i.e., super-user). 

To use su, the appropriate password must be supplied (unless you are already root). If the password is correct, su executes a new shell with the real and effective user ID, real and effective group ID, and group access list set to that of the specified user.  The previously defined HOME and ENV environment variables are removed unless the - option is specified.  The new shell is the optional program named in the shell field of the specified user’s password file entry (see passwd(4)), or /bin/sh if none is specified (see sh(1)). To restore normal user ID privileges, type an EOF to the new shell. 

Any additional arguments given on the command line are passed to the program invoked as the shell, permitting the super-user to run shell procedures with restricted privileges.  When using programs such as the Bourne shell (see sh-bourne(1)), an arg of the form -c string executes string via 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 similar in behavior to the Bourne shell.  If the first argument to su is a -, the environment is 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 unchanged, except that $PATH, is unconditionally set to /bin:/etc:/usr/bin for root.  Note that if the optional program used as the shell is /bin/sh, the user’s .profile can check arg0 for -sh or -su to determine if it was invoked by the login or su command (see login(1) or su(1), respectively). If the user’s program is other than /bin/sh, then .profile is invoked with an arg0 of -program by both login and su. 

The - option always resets $PATH to /bin:/etc:/usr/bin for the super-user, and /bin:/etc:/usr/bin for all others.  However, the files /etc/profile and .profile are normally executed anyway, thus restoring the intended value of $PATH. 

All attempts to become another user are logged in /usr/adm/sulog, including failures.  Successful attempts are flagged with +, failures with -. 

EXTERNAL INFLUENCES

Environment Variables

LANG determines the language in which messages are displayed. 

If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG. 

If any internationalization variable contains an invalid setting, su behaves as if all internationalization variables are set to "C".  See environ(5).

International Code Set Support

Characters in the 7-bit USASCII code sets are supported in login names (see ascii(5)).

EXAMPLES

Become user bin while retaining the previously exported environment ( $HOME and $ENV are no longer defined):

su bin

Become user bin but change the environment to what would be expected if bin had originally logged in:

su - bin

Execute command with the temporary environment and permissions of user bin:

su - bin -c command args

WARNINGS

After a successful password has been supplied (if needed), su uses information from /etc/passwd and /etc/logingroup to determine the user’s group id and group access list.  If /etc/group is linked to /etc/logingroup, and group membership for the user trying to log in is managed by the Network Information Service (NIS), and no NIS server is able to respond, su waits until a server does respond. 

FILES

$HOME/.profile user’s profile

/etc/logingroup system’s default group access list file

/etc/passwd system’s password file

/etc/profile system’s profile

/usr/adm/sulog log of all attempts

VARIABLES

HOME User’s home directory

LOGNAME User’s login name

PATH Command name search path

PS1 Default prompt

SHELL Name of the user’s shell

SEE ALSO

env(1), login(1), sh(1), initgroups(3C), group(4), passwd(4), profile(4), environ(5). 

STANDARDS CONFORMANCE

su: SVID2, XPG2

Hewlett-Packard Company  —  HP-UX Release 9.0: August 1992

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