1SU(1)                            User Commands                           SU(1)
2
3
4

NAME

6       su - run a command with substitute user and group ID
7

SYNOPSIS

9       su [options] [-] [user [argument...]]
10

DESCRIPTION

12       su allows to run commands with a substitute user and group ID.
13
14       When  called  without  arguments, su defaults to running an interactive
15       shell as root.
16
17       For backward compatibility, su  defaults  to  not  change  the  current
18       directory  and  to  only  set  the environment variables HOME and SHELL
19       (plus USER and LOGNAME if the target user is not root).  It  is  recom‐
20       mended  to always use the --login option (instead of its shortcut -) to
21       avoid side effects caused by mixing environments.
22
23       This version of su uses PAM for  authentication,  account  and  session
24       management.   Some  configuration options found in other su implementa‐
25       tions, such as support for a wheel group, have  to  be  configured  via
26       PAM.
27
28       su  is mostly designed for unprivileged users, the recommended solution
29       for privileged users (e.g. scripts executed by root) is to use non-set-
30       user-ID  command  runuser(1)  that  does not require authentication and
31       provide separate PAM configuration. If the PAM session is not  required
32       at all then the recommend solution is to use command setpriv(1).
33
34

OPTIONS

36       -c, --command=command
37              Pass command to the shell with the -c option.
38
39       -f, --fast
40              Pass  -f to the shell, which may or may not be useful, depending
41              on the shell.
42
43       -g, --group=group
44              Specify the primary group.  This option is available to the root
45              user only.
46
47       -G, --supp-group=group
48              Specify  a  supplemental group.  This option is available to the
49              root user only.  The first specified supplementary group is also
50              used as a primary group if the option --group is unspecified.
51
52       -, -l, --login
53              Start  the shell as a login shell with an environment similar to
54              a real login:
55
56                 o      clears all the environment variables except  TERM  and
57                        variables specified by --whitelist-environment
58
59                 o      initializes  the  environment  variables  HOME, SHELL,
60                        USER, LOGNAME, and PATH
61
62                 o      changes to the target user's home directory
63
64                 o      sets argv[0] of the shell to '-' in order to make  the
65                        shell a login shell
66
67       -m, -p, --preserve-environment
68              Preserve  the  entire  environment,  i.e.  it does not set HOME,
69              SHELL, USER nor LOGNAME.  This option is ignored if  the  option
70              --login is specified.
71
72       -P, --pty
73              Create pseudo-terminal for the session. The independent terminal
74              provides better security as user does not  share  terminal  with
75              the  original session.  This allow to avoid TIOCSTI ioctl termi‐
76              nal injection and another security attacks against terminal file
77              descriptors.  The  all session is also possible to move to back‐
78              ground (e.g. "su --pty - username -c  application  &").  If  the
79              pseudo-terminal  is  enabled  then  su  command works as a proxy
80              between the sessions (copy stdin and stdout).
81
82              This feature is EXPERIMENTAL for now and may be removed  in  the
83              next releases.
84
85
86       -s, --shell=shell
87              Run  the  specified  shell instead of the default.  The shell to
88              run is selected according to the following rules, in order:
89
90                 o      the shell specified with --shell
91
92                 o      the shell specified in the environment variable SHELL,
93                        if the --preserve-environment option is used
94
95                 o      the  shell  listed  in  the passwd entry of the target
96                        user
97
98                 o      /bin/sh
99
100              If the target user has a restricted shell (i.e.  not  listed  in
101              /etc/shells), the --shell option and the SHELL environment vari‐
102              ables are ignored unless the calling user is root.
103
104       --session-command=command
105              Same as -c but do not create a new session.  (Discouraged.)
106
107       -w, --whitelist-environment=list
108              Don't reset environment variables specified in  comma  separated
109              list  when  clears  environment  for  --login.  The whitelist is
110              ignored for the environment variables HOME,  SHELL,  USER,  LOG‐
111              NAME, and PATH.
112
113       -V, --version
114              Display version information and exit.
115
116       -h, --help
117              Display help text and exit.
118

SIGNALS

120       Upon  receiving  either  SIGINT,  SIGQUIT or SIGTERM, su terminates its
121       child and afterwards terminates itself with the received  signal.   The
122       child  is  terminated by SIGTERM, after unsuccessful attempt and 2 sec‐
123       onds of delay the child is killed by SIGKILL.
124

CONFIG FILES

126       su reads the /etc/default/su and /etc/login.defs  configuration  files.
127       The following configuration items are relevant for su(1):
128
129       FAIL_DELAY (number)
130           Delay  in  seconds in case of an authentication failure. The number
131           must be a non-negative integer.
132
133       ENV_PATH (string)
134           Defines the PATH environment variable  for  a  regular  user.   The
135           default value is /usr/local/bin:/bin:/usr/bin.
136
137       ENV_ROOTPATH (string)
138       ENV_SUPATH (string)
139           Defines  the PATH environment variable for root.  The default value
140           is /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin.
141
142       ALWAYS_SET_PATH (boolean)
143           If set to yes and --login and --preserve-environment were not spec‐
144           ified su initializes PATH.
145
146       The  environment  variable  PATH may be different on systems where /bin
147       and /sbin are merged into /usr.
148

EXIT STATUS

150       su normally returns the exit status of the command it executed.  If the
151       command  was  killed  by  a signal, su returns the number of the signal
152       plus 128.
153
154       Exit status generated by su itself:
155
156                 1      Generic error before executing the requested command
157
158                 126    The requested command could not be executed
159
160                 127    The requested command was not found
161

FILES

163       /etc/pam.d/su    default PAM configuration file
164       /etc/pam.d/su-l  PAM configuration file if --login is specified
165       /etc/default/su  command specific logindef config file
166       /etc/login.defs  global logindef config file
167

NOTES

169       For security reasons su always logs failed log-in attempts to the  btmp
170       file,  but it does not write to the lastlog file at all.  This solution
171       allows to control su behavior by PAM configuration.  If you want to use
172       the  pam_lastlog  module  to  print warning message about failed log-in
173       attempts then the pam_lastlog has to be configured to update the  last‐
174       log file as well. For example by:
175
176              session  required  pam_lastlog.so nowtmp
177

SEE ALSO

179       setpriv(1), login.defs(5), shells(5), pam(8), runuser(8)
180

HISTORY

182       This  su  command was derived from coreutils' su, which was based on an
183       implementation by David MacKenzie. The util-linux has  been  refactored
184       by Karel Zak.
185

AVAILABILITY

187       The  su command is part of the util-linux package and is available from
188       Linux  Kernel   Archive   ⟨https://www.kernel.org/pub/linux/utils/util-
189       linux/⟩.
190
191
192
193util-linux                         July 2014                             SU(1)
Impressum