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

NAME

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

SYNOPSIS

9       runuser [options] -u user [[--] command [argument...]]
10
11       runuser [options] [-] [user [argument...]]
12

DESCRIPTION

14       runuser allows to run commands with a substitute user and group ID.  If
15       the option -u is not given, it falls back  to  su-compatible  semantics
16       and  a  shell is executed.  The difference between the commands runuser
17       and su is that runuser does not ask for a password (because it  may  be
18       executed  by the root user only) and it uses a different PAM configura‐
19       tion.  The command runuser does not have to be installed with set-user-
20       ID permissions.
21
22       If  the PAM session is not required then recommended solution is to use
23       setpriv(1) command.
24
25       When called without arguments, runuser defaults to running an  interac‐
26       tive shell as root.
27
28       For  backward compatibility, runuser defaults to not change the current
29       directory and to only set the  environment  variables  HOME  and  SHELL
30       (plus  USER  and LOGNAME if the target user is not root).  This version
31       of runuser uses PAM for session management.
32

OPTIONS

34       -c, --command=command
35              Pass command to the shell with the -c option.
36
37       -f, --fast
38              Pass -f to the shell, which may or may not be  useful  depending
39              on the shell.
40
41       -g, --group=group
42              The  primary  group  to be used.  This option is allowed for the
43              root user only.
44
45       -G, --supp-group=group
46              Specify a supplemental group.  This option is available  to  the
47              root user only.  The first specified supplementary group is also
48              used as a primary group if the option --group is unspecified.
49
50       -, -l, --login
51              Start the shell as a login shell with an environment similar  to
52              a real login:
53
54                 o      clears  all  the environment variables except for TERM
55                        and variables specified by --whitelist-environment
56
57                 o      initializes the  environment  variables  HOME,  SHELL,
58                        USER, LOGNAME, PATH
59
60                 o      changes to the target user's home directory
61
62                 o      sets  argv[0] of the shell to '-' in order to make the
63                        shell a login shell
64
65       -P, --pty
66              Create pseudo-terminal for the session. The independent terminal
67              provides  better  security  as user does not share terminal with
68              the original session.  This allow to avoid TIOCSTI ioctl  termi‐
69              nal injection and another security attacks against terminal file
70              descriptors. The all session is also possible to move  to  back‐
71              ground  (e.g. "runuser --pty -u username -- command &").  If the
72              pseudo-terminal is enabled then runuser command works as a proxy
73              between the sessions (copy stdin and stdout).
74
75              This feature is mostly designed for interactive sessions. If the
76              standard input is not a terminal, but  for  example  pipe  (e.g.
77              echo  "date"  |  runuser  --pty  -u user) than ECHO flag for the
78              pseudo-terminal is disabled to avoid messy output.
79
80       -m, -p, --preserve-environment
81              Preserve the entire environment, i.e.  it  does  not  set  HOME,
82              SHELL,  USER  nor  LOGNAME.  The option is ignored if the option
83              --login is specified.
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       -w, --whitelist-environment=list
107              Don't  reset  environment variables specified in comma separated
108              list when clears  environment  for  --login.  The  whitelist  is
109              ignored  for  the  environment variables HOME, SHELL, USER, LOG‐
110              NAME, and PATH.
111
112       -V, --version
113              Display version information and exit.
114
115       -h, --help
116              Display help text and exit.
117

CONFIG FILES

119       runuser reads the /etc/default/runuser and  /etc/login.defs  configura‐
120       tion  files.   The  following  configuration  items  are  relevant  for
121       runuser:
122
123       ENV_PATH (string)
124           Defines the PATH environment variable  for  a  regular  user.   The
125           default value is /usr/local/bin:/bin:/usr/bin.
126
127       ENV_ROOTPATH (string)
128       ENV_SUPATH (string)
129           Defines  the  PATH environment variable for root.  ENV_SUPATH takes
130           precedence.  The default value  is  /usr/local/sbin:/usr/local/bin:
131           /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 runuser initializes PATH.
136
137       The environment variable PATH may be different on  systems  where  /bin
138       and /sbin are merged into /usr.
139

EXIT STATUS

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

FILES

154       /etc/pam.d/runuser
155                        default PAM configuration file
156       /etc/pam.d/runuser-l
157                        PAM configuration file if --login is specified
158       /etc/default/runuser
159                        runuser specific logindef config file
160       /etc/login.defs  global logindef config file
161

SEE ALSO

163       setpriv(1), su(1), login.defs(5), shells(5), pam(8)
164

HISTORY

166       This   runuser  command was derived from coreutils' su, which was based
167       on an implementation by David MacKenzie, and the Fedora runuser command
168       by Dan Walsh.
169

AVAILABILITY

171       The  runuser command is part of the util-linux package and is available
172       from Linux Kernel Archive ⟨https://www.kernel.org/pub/linux/utils/util-
173       linux/⟩.
174
175
176
177util-linux                         July 2014                        RUNUSER(1)
Impressum