p When executed by a user, the .Ar login user's password is requested. When using Kerberos, the password for .Ar login (or for .Dq Ar login Ns .root , if no login is provided) is requested, and .Nm switches to that user and group ID after obtaining a Kerberos ticket granting ticket. A shell is then executed, and any additional .Ar "shell arguments" after the login name are passed to the shell. .Nm will resort to the local password file to find the password for .Ar login if there is a Kerberos error. If .Nm is executed by root, no password is requested and a shell with the appropriate user ID is executed; no additional Kerberos tickets are obtained.
p Alternatively, if the user enters the password "s/key", authentication will use the S/Key one-time password system as described in .Xr skey 1 . S/Key is a Trademark of Bellcore.
p By default, the environment is unmodified with the exception of .Ev LOGNAME , .Ev USER , .Ev HOME , .Ev SHELL , and .Ev SU_FROM . .Ev HOME and .Ev SHELL are set to the target login's default values. .Ev LOGNAME and .Ev USER are set to the target login, unless the target login has a user ID of 0, in which case they are unmodified. .Ev SU_FROM is set to the caller's login. The invoked shell is the target login's. With the exception of .Ev SU_FROM this is the traditional behavior of .Nm .
p The options are as follows: l -tag -width Ds t Fl K Do not attempt to use Kerberos to authenticate the user. t Fl c Specify a login class. You may only override the default class if you're already root. See .Xr login.conf 5 for details. t Fl d Same as .Fl l , but does not change the current directory. t Fl f If the invoked shell is .Xr csh 1 , this option prevents it from reading the .Dq Pa .cshrc file. If the invoked shell is .Xr sh 1 , or .Xr ksh 1 , this option unsets .Ev ENV , thus preventing the shell from executing the startup file pointed to by this variable. t Fl l Simulate a full login. The environment is discarded except for .Ev HOME , .Ev SHELL , .Ev PATH , .Ev TERM , .Ev LOGNAME , .Ev USER , and .Ev SU_FROM . .Ev HOME , .Ev SHELL , and .Ev SU_FROM are modified as above. .Ev LOGNAME and .Ev USER are set to the target login. .Ev PATH is set to the path specified in the
a /etc/login.conf file (or to the default of .Dq Pa /usr/bin:/bin:/usr/pkg/bin:/usr/local/bin ). .Ev TERM is imported from your current environment. The invoked shell is the target login's, and .Nm will change directory to the target login's home directory. t Fl Same as .Fl l . t Fl m 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 .Xr getusershell 3 ) and the caller's real uid is non-zero, .Nm will fail. .El
p The .Fl l and .Fl m options are mutually exclusive; the last one specified overrides any previous ones.
p Only users in group .Dq wheel (normally gid 0), as listed in
a /etc/group , can .Nm to .Dq root , unless group wheel does not exist or has no members. (If you do not want anybody to be able to .Nm to .Dq root , make .Dq root the only member of group .Dq wheel , which is the default.)
p For sites with very large user populations, group .Dq wheel can contain the names of other groups that will be considered authorized to .Nm to .Dq root .
p
By default (unless the prompt is reset by a startup file) the super-user
prompt is set to
.Dq Sy #
to remind one of its awesome power.
.Sh COMPILATION OPTIONS
Several compilation time options are available that alter the program's
behavior.
These options are:
l -tag -width "SU_INDIRECT_GROUP" t SU_GROUP If defined, it changes the default group that is allowed to become
.Dq root
from
.Dq wheel
to the specified string.
For pam this can be done by adding a line to /etc/pam.d/su such as:
auth requisite pam_group.so no_warn group=groupname root_only fail_safe
t SU_ROOTAUTH If defined, it specifies a group whose members are allowed to become
.Dq root
by supplying their own password instead of the
.Dq root
one.
For pam this can be done by adding a line to /etc/pam.d/su such as
auth sufficient pam_group.so no_warn group=rootauth root_only fail_safe authenticate
t SU_INDIRECT_GROUP If defined, the
.Ar SU_GROUP
and
.Ar SU_ROOTAUTH
groups are treated as indirect groups.
The group members of those two groups are treated as groups themselves.
This option is not supported under pam.
.El
.Sh EXIT STATUS
.Nm
returns the exit status of the executed subshell, or 1 if any error
occurred while switching privileges.
.Sh ENVIRONMENT
Environment variables used by
.Nm :
l -tag -width "HOME" t Ev HOME Default home directory of real user ID unless modified as
specified above.
t Ev LOGNAME The user ID is always the effective ID (the target user ID) after an
.Nm
unless the user ID is 0 (root).
t Ev PATH Default search path of real user ID unless modified as specified above.
t Ev TERM Provides terminal type which may be retained for the substituted
user ID.
t Ev USER The user ID is always the effective ID (the target user ID) after an
.Nm
unless the user ID is 0 (root).
.El
.Sh EXAMPLES
To become user username and use the same environment as in original shell, execute:
d -literal -offset indent su username
.Ed
p To become user username and use environment as if full login would be performed, execute: d -literal -offset indent su -l username .Ed
p When a .Fl c option is included .Em after the .Ar login name it is not a .Nm option, because any arguments after the .Ar login are passed to the shell. (See .Xr csh 1 , .Xr ksh 1 or .Xr sh 1 for details.) To execute arbitrary command with privileges of user .Em username , execute: d -literal -offset indent su username -c "command args" .Ed .Sh SEE ALSO .Xr csh 1 , .Xr kinit 1 , .Xr login 1 , .Xr sh 1 , .Xr skey 1 , .Xr setusercontext 3 , .Xr group 5 , .Xr login.conf 5 , .Xr passwd 5 , .Xr environ 7 , .Xr kerberos 8 .Sh HISTORY A .Nm command existed in .At v5 (and probably earlier).