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 can be used to run commands with a substitute user and group
15       ID. If the option -u is not given, runuser falls back to su-compatible
16       semantics and a shell is executed. The difference between the commands
17       runuser and su is that runuser does not ask for a password (because it
18       may be executed by the root user only) and it uses a different PAM
19       configuration. The command runuser does not have to be installed with
20       set-user-ID permissions.
21
22       If the PAM session is not required, then the recommended solution is to
23       use the setpriv(1) command.
24
25       When called without arguments, runuser defaults to running an
26       interactive shell as root.
27
28       For backward compatibility, runuser defaults to not changing the
29       current directory and to setting only the environment variables HOME
30       and SHELL (plus USER and LOGNAME if the target user is not root). This
31       version of runuser uses PAM for session management.
32
33       Note that runuser in all cases use PAM (pam_getenvlist()) to do the
34       final environment modification. Command-line options such as --login
35       and --preserve-environment affect the environment before it is modified
36       by PAM.
37
38       Since version 2.38 runuser resets process resource limits RLIMIT_NICE,
39       RLIMIT_RTPRIO, RLIMIT_FSIZE, RLIMIT_AS and RLIMIT_NOFILE.
40

OPTIONS

42       -c, --command=command
43           Pass command to the shell with the -c option.
44
45       -f, --fast
46           Pass -f to the shell, which may or may not be useful, depending on
47           the shell.
48
49       -g, --group=group
50           The primary group to be used. This option is allowed for the root
51           user only.
52
53       -G, --supp-group=group
54           Specify a supplementary group. This option is available to the root
55           user only. The first specified supplementary group is also used as
56           a primary group if the option --group is not specified.
57
58       -, -l, --login
59           Start the shell as a login shell with an environment similar to a
60           real login:
61
62           •   clears all the environment variables except for TERM and
63               variables specified by --whitelist-environment
64
65           •   initializes the environment variables HOME, SHELL, USER,
66               LOGNAME, and PATH
67
68           •   changes to the target user’s home directory
69
70           •   sets argv[0] of the shell to '-' in order to make the shell a
71               login shell
72
73       -P, --pty
74           Create a pseudo-terminal for the session. The independent terminal
75           provides better security as the user does not share a terminal with
76           the original session. This can be used to avoid TIOCSTI ioctl
77           terminal injection and other security attacks against terminal file
78           descriptors. The entire session can also be moved to the background
79           (e.g., runuser --pty -u username -- command &). If the
80           pseudo-terminal is enabled, then runuser works as a proxy between
81           the sessions (sync stdin and stdout).
82
83           This feature is mostly designed for interactive sessions. If the
84           standard input is not a terminal, but for example a pipe (e.g.,
85           echo "date" | runuser --pty -u user), then the ECHO flag for the
86           pseudo-terminal is disabled to avoid messy output.
87
88       -m, -p, --preserve-environment
89           Preserve the entire environment, i.e., do not set HOME, SHELL, USER
90           or LOGNAME. The option is ignored if the option --login is
91           specified.
92
93       -s, --shell=shell
94           Run the specified shell instead of the default. The shell to run is
95           selected according to the following rules, in order:
96
97           •   the shell specified with --shell
98
99           •   the shell specified in the environment variable SHELL if the
100               --preserve-environment option is used
101
102           •   the shell listed in the passwd entry of the target user
103
104           •   /bin/sh
105
106               If the target user has a restricted shell (i.e., not listed in
107               /etc/shells), then the --shell option and the SHELL environment
108               variables are ignored unless the calling user is root.
109
110       --session-command=command
111           Same as -c, but do not create a new session. (Discouraged.)
112
113       -w, --whitelist-environment=list
114           Don’t reset the environment variables specified in the
115           comma-separated list when clearing the environment for --login. The
116           whitelist is ignored for the environment variables HOME, SHELL,
117           USER, LOGNAME, and PATH.
118
119       -h, --help
120           Display help text and exit.
121
122       -V, --version
123           Print version and exit.
124

CONFIG FILES

126       runuser reads the /etc/default/runuser and /etc/login.defs
127       configuration files. The following configuration items are relevant for
128       runuser:
129
130       ENV_PATH (string)
131           Defines the PATH environment variable for a regular user. The
132           default value is /usr/local/bin:/bin:/usr/bin.
133
134       ENV_ROOTPATH (string), ENV_SUPATH (string)
135           Defines the PATH environment variable for root. ENV_SUPATH takes
136           precedence. The default value is
137           /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin.
138
139       ALWAYS_SET_PATH (boolean)
140           If set to yes and --login and --preserve-environment were not
141           specified runuser initializes PATH.
142
143       The environment variable PATH may be different on systems where /bin
144       and /sbin are merged into /usr; this variable is also affected by the
145       --login command-line option and the PAM system setting (e.g.,
146       pam_env(8)).
147

EXIT STATUS

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

FILES

165       /etc/pam.d/runuser
166           default PAM configuration file
167
168       /etc/pam.d/runuser-l
169           PAM configuration file if --login is specified
170
171       /etc/default/runuser
172           runuser specific logindef config file
173
174       /etc/login.defs
175           global logindef config file
176

HISTORY

178       This runuser command was derived from coreutils' su, which was based on
179       an implementation by David MacKenzie, and the Fedora runuser command by
180       Dan Walsh.
181

SEE ALSO

183       setpriv(1), su(1), login.defs(5), shells(5), pam(8)
184

REPORTING BUGS

186       For bug reports, use the issue tracker at
187       https://github.com/util-linux/util-linux/issues.
188

AVAILABILITY

190       The runuser command is part of the util-linux package which can be
191       downloaded from Linux Kernel Archive
192       <https://www.kernel.org/pub/linux/utils/util-linux/>.
193
194
195
196util-linux 2.38                   2022-02-17                        RUNUSER(1)
Impressum