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
By default, the environment is unmodified with the exception of
are set to the target login's default
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
variable and umask value
always set according to the /etc/login.conf
The options are as follows:
- Same as the -l option
- Specify an authentication type such as “skey”
- 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
- This is shorthand for
passwd”, provided for backwards
- Loop until a correct username and password combination is
entered, similar to
that in this mode target login must be
specified explicitly, either on the command line or interactively.
Additionally, su will prompt for the password
even when invoked by root.
- Simulate a full login. The environment is discarded except
SHELL are modified as above.
USER are set to the target login.
PATH is set to the value specified by
the “path” entry in
TERM is imported from your current
environment. The invoked shell is the target login's, and
su will 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
and the caller's real UID is non-zero, su
- 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 the -m option is
are mutually exclusive; the last one specified overrides any previous ones.
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 -c
option as understood by most shells. Note that -c
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
to add them to the “wheel” group; they must explicitly be listed
. If no one is in the
“wheel” group, it is ignored, and anyone who knows the root
password is permitted to su
By default (unless the prompt is reset by a startup file) the superuser prompt
is set to “#
” to remind one of its
- Default home directory of real user ID unless modified as
- The user ID is always the effective ID (the target user ID)
after an su unless the user ID is 0
- Default search path of real user ID unless modified as
- 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
Same as above, but the target command is run with the resource limits of the
login class “staff”. Note that the first
option applies to
while the second is an argument to the shell.
$ su -c staff bin -c 'makewhatis
Pretend a login for user “foo”:
$ su -l foo
Same as above, but use S/Key for authentication:
$ su -a skey -l foo
command appeared in
Version 7 AT&T UNIX
The login name is not optional for root if there are shell arguments.