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
57
58                 o      initializes the  environment  variables  HOME,  SHELL,
59                        USER, LOGNAME, and PATH
60
61                 o      changes to the target user's home directory
62
63                 o      sets  argv[0] of the shell to '-' in order to make the
64                        shell a login shell
65
66       -m, -p, --preserve-environment
67              Preserve the entire environment, i.e.  it  does  not  set  HOME,
68              SHELL,  USER  nor LOGNAME.  This option is ignored if the option
69              --login is specified.
70
71       -P, --pty
72              Create pseudo-terminal for the session. The independent terminal
73              provides  better  security  as user does not share terminal with
74              the original session.  This allow to avoid TIOCSTI ioctl  termi‐
75              nal injection and another security attacks against terminal file
76              descriptors. The all session is also possible to move  to  back‐
77              ground  (e.g.  "su  --pty  -  usename -c application &"). If the
78              pseudo-terminal is enabled then su  command  works  as  a  proxy
79              between the sessions (copy stdin and stdout).
80
81              This  feature  is EXPERIMENTAL for now and may be removed in the
82              next releases.
83
84
85       -s, --shell=shell
86              Run the specified shell instead of the default.   The  shell  to
87              run is selected according to the following rules, in order:
88
89                 o      the shell specified with --shell
90
91                 o      the shell specified in the environment variable SHELL,
92                        if the --preserve-environment option is used
93
94                 o      the shell listed in the passwd  entry  of  the  target
95                        user
96
97                 o      /bin/sh
98
99              If  the  target  user has a restricted shell (i.e. not listed in
100              /etc/shells), the --shell option and the SHELL environment vari‐
101              ables are ignored unless the calling user is root.
102
103       --session-command=command
104              Same as -c but do not create a new session.  (Discouraged.)
105
106       -V, --version
107              Display version information and exit.
108
109       -h, --help
110              Display help text and exit.
111

SIGNALS

113       Upon  receiving  either  SIGINT,  SIGQUIT or SIGTERM, su terminates its
114       child and afterwards terminates itself with the received signal.
115

CONFIG FILES

117       su reads the /etc/default/su and /etc/login.defs  configuration  files.
118       The following configuration items are relevant for su(1):
119
120       FAIL_DELAY (number)
121           Delay  in  seconds in case of an authentication failure. The number
122           must be a non-negative integer.
123
124       ENV_PATH (string)
125           Defines the PATH environment variable  for  a  regular  user.   The
126           default value is /usr/local/bin:/bin:/usr/bin.
127
128       ENV_ROOTPATH (string)
129       ENV_SUPATH (string)
130           Defines  the PATH environment variable for root.  The default value
131           is /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin.
132
133       ALWAYS_SET_PATH (boolean)
134           If set to yes and --login and --preserve-environment were not spec‐
135           ified su initializes PATH.
136

EXIT STATUS

138       su normally returns the exit status of the command it executed.  If the
139       command was killed by a signal, su returns the  number  of  the  signal
140       plus 128.
141
142       Exit status generated by su itself:
143
144                 1      Generic error before executing the requested command
145
146                 126    The requested command could not be executed
147
148                 127    The requested command was not found
149

FILES

151       /etc/pam.d/su    default PAM configuration file
152       /etc/pam.d/su-l  PAM configuration file if --login is specified
153       /etc/default/su  command specific logindef config file
154       /etc/login.defs  global logindef config file
155

NOTES

157       For  security reasons su always logs failed log-in attempts to the btmp
158       file, but it does not write to the lastlog file at all.  This  solution
159       allows to control su behavior by PAM configuration.  If you want to use
160       the pam_lastlog module to print warning  message  about  failed  log-in
161       attempts  then the pam_lastlog has to be configured to update the last‐
162       log file as well. For example by:
163
164              session  required  pam_lastlog.so nowtmp
165

SEE ALSO

167       setpriv(1), login.defs(5), shells(5), pam(8), runuser(8)
168

HISTORY

170       This su command was derived from coreutils' su, which was based  on  an
171       implementation  by  David MacKenzie. The util-linux has been refactored
172       by Karel Zak.
173

AVAILABILITY

175       The su command is part of the util-linux package and is available  from
176       Linux   Kernel   Archive  ⟨https://www.kernel.org/pub/linux/utils/util-
177       linux/⟩.
178
179
180
181util-linux                         July 2014                             SU(1)
Impressum