|SU(1)||General Commands Manual||SU(1)|
suutility 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. By default, the environment is unmodified with the exception of
SHELLare set to the target login's default values.
USERare set to the target login, unless the target login has a user ID of 0 and the
-lflag was not specified, in which case it is unmodified. The invoked shell is the target login's. This is the traditional behavior of
su. If not using
-mand the target login has a user ID of 0 then the
PATHvariable and umask value (see umask(2)) are always set according to the /etc/login.conf file (see login.conf(5)). The options are as follows:
-apasswd”, provided for backwards compatibility.
suwill prompt for the password even when invoked by root.
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.
-moption is specified.
-moptions 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
-coption as understood by most shells. Note that
-cusually expects a single argument only; you have to quote it when passing multiple words. If group 0 (normally “wheel”) has users listed then only those users can
suto “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
suto “root”. By default (unless the prompt is reset by a startup file) the superuser prompt is set to “#” to remind one of its awesome power.
suunless the user ID is 0 (root).
$ su bin -c makewhatis
$ su bin -c 'makewhatis /usr/local/man'
-coption applies to
suwhile the second is an argument to the shell.
$ su -c staff bin -c 'makewhatis /usr/local/man'
$ su -l foo
$ su -a skey -l foo
sucommand appeared in Version 7 AT&T UNIX.
|July 30, 2015||OpenBSD-6.1|