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 mostly designed for interactive sessions. If the
83              standard  input  is  not  a terminal, but for example pipe (e.g.
84              echo "date" | su --pty) than ECHO flag for  the  pseudo-terminal
85              is disabled to avoid messy output.
86
87       -s, --shell=shell
88              Run  the  specified  shell instead of the default.  The shell to
89              run is selected according to the following rules, in order:
90
91                 o      the shell specified with --shell
92
93                 o      the shell specified in the environment variable SHELL,
94                        if the --preserve-environment option is used
95
96                 o      the  shell  listed  in  the passwd entry of the target
97                        user
98
99                 o      /bin/sh
100
101              If the target user has a restricted shell (i.e.  not  listed  in
102              /etc/shells), the --shell option and the SHELL environment vari‐
103              ables are ignored unless the calling user is root.
104
105       --session-command=command
106              Same as -c but do not create a new session.  (Discouraged.)
107
108       -w, --whitelist-environment=list
109              Don't reset environment variables specified in  comma  separated
110              list  when  clears  environment  for  --login.  The whitelist is
111              ignored for the environment variables HOME,  SHELL,  USER,  LOG‐
112              NAME, and PATH.
113
114       -V, --version
115              Display version information and exit.
116
117       -h, --help
118              Display help text and exit.
119

SIGNALS

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

CONFIG FILES

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

EXIT STATUS

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

FILES

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

NOTES

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

SEE ALSO

181       setpriv(1), login.defs(5), shells(5), pam(8), runuser(8)
182

HISTORY

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

AVAILABILITY

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