substitute user identity
su utility allows a user to run a
shell with the user and group ID of another user without having to log out
and in as that other user.
If Kerberos is in use, the password for
login (or for
“login/root”, if no login is provided)
is requested, and
su switches to that user and group
ID after obtaining a Kerberos ticket granting access. A shell is then
executed, and any additional shell arguments after the
login name are passed to the shell. If Kerberos is not configured or if
there is a Kerberos error,
su falls back to local
password authentication to validate the password for
su is executed by
root, no password is requested and a shell with the appropriate user ID is
executed; no additional Kerberos tickets are obtained.
By default, the environment is unmodified with the exception of
SHELL are set to
the target login's default values.
USER are set to the target login, unless the target
login has a user ID of 0 and the
-l flag was not
specified, in which case it is unmodified. The invoked shell is the target
login's. This is the traditional behavior of
If not using
-m and the target login has a
user ID of 0 then the
PATH variable and umask value
(see umask(2)) are always set according to the
/etc/login.conf file (see
The options are as follows:
- Same as the
- Specify an authentication type such as “skey”, “securid”, or “krb5”.
- Specify a login class. You may only override the default class if you're already root.
- If the invoked shell is csh(1), this option prevents it from reading the “.cshrc” file.
- Do not attempt to use Kerberos to authenticate the user. This is shorthand
-apasswd”, provided for backwards compatibility.
- Loop until a correct username and password combination is entered, similar
to login(1). Note that in this mode target login
must be specified explicitly, either on the command line or interactively.
suwill prompt for the password even when invoked by root.
- Simulate a full login. The environment is discarded except for
SHELLare modified as above.
USERare set to the target login.
PATHis set to the value specified by the “path” entry in login.conf(5).
TERMis imported from your current environment. The invoked shell is the target login's, and
suwill change directory to the target login's home directory.
- Leave the environment unmodified. The invoked shell is your login shell,
and no directory changes are made. As a security precaution, if the target
user's shell is a non-standard shell (as defined by
getusershell(3)) and the caller's real UID is non-zero,
- Specify the path to an alternate login shell. You may only override the
shell if you're already root. This option will override the shell even if
-moption is specified.
options are mutually exclusive; the last one specified overrides any
If the optional shell arguments are provided
on the command line, they are passed to the login shell of the target login.
This allows it to pass arbitrary commands via the
option as understood by most shells. Note that
usually expects a single argument only; you have to quote it when passing
If group 0 (normally “wheel”) has users listed then
only those users can
su to “root”. It
is not sufficient to change a user's /etc/passwd
entry to add them to the “wheel” group; they must explicitly
be listed in /etc/group. If no one is in the
“wheel” group, it is ignored, and anyone who knows the root
password is permitted to
By default (unless the prompt is reset by a startup file) the superuser prompt is set to “#” to remind one of its awesome power.
- Default home directory of real user ID unless modified as specified above.
- The user ID is always the effective ID (the target user ID) after an
suunless the user ID is 0 (root).
- Default search path of real user ID unless modified as specified above.
- Provides terminal type which may be retained for the substituted user ID.
- Same as
Run the command “makewhatis” as user “bin”. You will be asked for bin's password unless your real UID is 0.
$ su bin -c makewhatis
Same as above, but the target command consists of more than a single word:
$ su bin -c 'makewhatis /usr/local/man'
Same as above, but the target command is run with the resource
limits of the login class “staff”. Note that the first
-c option applies to
while the second is an argument to the shell.
$ su -c staff bin -c 'makewhatis /usr/local/man'
Pretend a login for user “foo”:
$ su -l foo
Same as above, but use S/Key for authentication:
$ su -a skey -l foo
csh(1), kinit(1), login(1), sh(1), skey(1), setusercontext(3), group(5), login.conf(5), passwd(5), environ(7), sudo(8)
su command appeared in
Version 7 AT&T UNIX.
The login name is not optional for root if there are shell arguments.