HP-UX Reference (11i v2 07/12) - 1 User Commands N-Z (vol 2)

s
su(1) su(1)
NAME
su - switch user
SYNOPSIS
su [-][username [arguments]]
su [-]-d[username]
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 and is not using
the -d option. If a valid password 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.
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)).
Options
su recognizes the following options:
- If the - option is specified, the new shell starts up as if the new user had initiated a new
login session. If the - option is omitted, the new shell starts as if a subshell was invoked.
See more details below.
-d If DCE (Distributed Computing Environment) is being used as the authentication mechan-
ism, the -d option must be specified. With this option, even superuser will be prompted for
the user’s password. The reason for this is because DCE credentials for a user cannot be
obtained without that user’s password.
This option cannot be used with shell arguments.
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 and ENV environment variables are removed.
The rest of the environment is retained.
HP-UX 11i Version 2: December 2007 Update 1 Hewlett-Packard Company 319