HP-UX Reference (11i v1 05/09) - 1 User Commands N-Z (vol 2)

s
su(1) su(1)
NAME
su - switch user
SYNOPSIS
su [-][username [arguments]]
DESCRIPTION
The
su (set user or superuser) command allows one user to become another user without logging out.
username is the name of a user defined in the
/etc/passwd file (see passwd(4)). The default name is
root (that is, superuser).
To use su, the appropriate password must be supplied unless the current user is superuser. If a valid pass-
word is entered, 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 new shell is the one specified in the shell field of
the new user’s entry in the password file,
/etc/passwd .
The arguments are passed along to the new shell for execution, permitting the user to run shell procedures
with the new user’s privileges.
When exiting from the new shell, the previous username and environment are restored.
If the
- option is specified, the new shell starts up as if the new user had initiated a new login session.
Exceptions are as follows:
The HOME variable is reset to the new user’s home directory.
If the new user name is root, the path and prompt variables are reset:
PATH=/usr/bin:/usr/sbin:/sbin
PS1=#
For other user names:
PATH=/usr/bin
PS1=$
The TERM variable is retained.
The rest of the environment is deleted and reset to the login state. However, the login files are nor-
mally executed anyway, usually restoring the expected value of PATH and other variables.
If the - option is omitted, the new shell starts as if a subshell was invoked. Exceptions are as follows:
If the new user name is root, the path and prompt variables are reset:
PATH=/usr/bin:/usr/sbin:/sbin
PS1=#
The previously defined HOME , ENV , LD_PRELOAD , LD_LIBRARY_PATH
and SHLIB_PATH
environment variables are removed. See the description of the SU_KEEP_ENV_VARS
parameter in
the security(4) manual page for information about altering this behavior.
The rest of the environment is retained.
If the shell specified in
/etc/passwd is /usr/bin/sh , su sets the value of parameter 0 in the new
shell (referenced as $0)tosu. If the - option of the su command is specified, su sets parameter 0 to
-su.
If the shell specified in /etc/passwd is not /usr/bin/sh, su sets the value of parameter 0 in the
new shell to shellname. If the - option of the su command is specified, su sets parameter 0 to
-shellname. For example, if the Korn shell is invoked, the value of shellname will be either ksh or -ksh.
By comparison, the login command always sets parameter 0 to -shellname.
All attempts to become another user are logged in /var/adm/sulog, including failures. Successful
attempts are flagged with +; failures, with -. They are also logged with syslog() (see syslog(3C)).
HP-UX Smart Card Login
If the user account is configured to use a Smart Card, the user password is stored in the card. This pass-
word has characteristics identical to a normal password stored on the system.
Section 1948 Hewlett-Packard Company 1 HP-UX 11i Version 1: September 2005