Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ su(1) — HP-UX 5.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

env(1)

login(1)

sh(1)

initgroups(3C)

group(5)

passwd(5)

profile(5)

environ(7)

SU(1)

NAME

su − become super-user or another user

SYNOPSIS

su [ − ] [ name [ arg ... ] ]

HP-UX COMPATIBILITY

Level: HP-UX/STANDARD

Origin: System V

DESCRIPTION

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

To use su, the appropriate password must be supplied (unless one is already root).  If the password is correct, su will execute 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 new shell will be 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 like sh(1), an arg of the form −c string executes string via the shell and an arg of −r will give 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(1).  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 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 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(1) and su(1). 

The − option always resets $PATH to /bin:/etc:/usr/bin for the super-user, and /bin:/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 "-". 

EXAMPLES

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

su bin

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

su - bin

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

su - bin -c "command args"

FILES

/etc/passwdsystem’s password file
/etc/logingroupsystem’s default group access list file
/etc/profilesystem’s profile
$HOME/.profileuser’s profile
/usr/adm/sulog          log of all attempts

VARIABLES

HOME                    the user’s home directory
LOGNAME                 the user’s login name
PATH                    the command name search path
PS1                     the default prompt
SHELL                   the name of the user’s shell

HARDWARE DEPENDENCIES

Multiple groups are not currently supported on Series 500 and the Integral PC. 

SEE ALSO

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

Hewlett-Packard  —  last mod. May 11, 2021

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