]> git.ipfire.org Git - thirdparty/util-linux.git/blame - login-utils/runuser.1.adoc
Merge branch 'PR/ipcs-fix-counters' of github.com:karelzak/util-linux-work
[thirdparty/util-linux.git] / login-utils / runuser.1.adoc
CommitLineData
295b3979 1//po4a: entry man manual
a7574d88
MB
2= runuser(1)
3:doctype: manpage
f42ed819 4:man manual: User Commands
a7574d88
MB
5:man source: util-linux {release-version}
6:page-layout: base
7:command: runuser
8
9== NAME
10
11runuser - run a command with substitute user and group ID
12
13== SYNOPSIS
14
15*runuser* [options] *-u* _user_ [[--] _command_ [_argument_...]]
16
17*runuser* [options] [*-*] [_user_ [_argument_...]]
18
19== DESCRIPTION
20
21*runuser* can be used to run commands with a substitute user and group ID. If the option *-u* is not given, *runuser* falls back to *su*-compatible semantics and a shell is executed. The difference between the commands *runuser* and *su* is that *runuser* does not ask for a password (because it may be executed by the root user only) and it uses a different PAM configuration. The command *runuser* does not have to be installed with set-user-ID permissions.
22
23If the PAM session is not required, then the recommended solution is to use the *setpriv*(1) command.
24
25When called without arguments, *runuser* defaults to running an interactive shell as _root_.
26
27For backward compatibility, *runuser* defaults to not changing the current directory and to setting only the environment variables *HOME* and *SHELL* (plus *USER* and *LOGNAME* if the target _user_ is not root). This version of *runuser* uses PAM for session management.
28
29Note that *runuser* in all cases use PAM (pam_getenvlist()) to do the final environment modification. Command-line options such as *--login* and *--preserve-environment* affect the environment before it is modified by PAM.
30
be3acd23 31Since version 2.38 *runuser* resets process resource limits RLIMIT_NICE, RLIMIT_RTPRIO, RLIMIT_FSIZE, RLIMIT_AS and RLIMIT_NOFILE.
e5496191 32
a7574d88
MB
33== OPTIONS
34
35*-c*, *--command*=_command_::
62fde24f 36Pass _command_ to the shell with the *-c* option.
a7574d88
MB
37
38*-f*, *--fast*::
62fde24f 39Pass *-f* to the shell, which may or may not be useful, depending on the shell.
a7574d88
MB
40
41*-g*, *--group*=_group_::
62fde24f 42The primary group to be used. This option is allowed for the root user only.
a7574d88
MB
43
44*-G*, *--supp-group*=_group_::
62fde24f 45Specify a supplementary group. This option is available to the root user only. The first specified supplementary group is also used as a primary group if the option *--group* is not specified.
a7574d88
MB
46
47*-*, *-l*, *--login*::
62fde24f
MB
48Start the shell as a login shell with an environment similar to a real login:
49+
e08e3d58 50* clears all the environment variables except for *TERM* and variables specified by *--whitelist-environment*
62fde24f
MB
51* initializes the environment variables *HOME*, *SHELL*, *USER*, *LOGNAME*, and *PATH*
52* changes to the target user's home directory
53* sets argv[0] of the shell to '*-*' in order to make the shell a login shell
a7574d88 54
0bf93755
SP
55*-m*, *-p*, *--preserve-environment*::
56Preserve the entire environment, i.e., do not set *HOME*, *SHELL*, *USER* or *LOGNAME*. The option is ignored if the option *--login* is specified.
57
a7574d88 58*-P*, *--pty*::
bd67ca44 59Create a pseudo-terminal for the session. The independent terminal provides better security as the user does not share a terminal with the original session. This can be used to avoid TIOCSTI ioctl terminal injection and other security attacks against terminal file descriptors. The entire session can also be moved to the background (e.g., *runuser --pty* *-u* _username_ *--* _command_ *&*). If the pseudo-terminal is enabled, then *runuser* works as a proxy between the sessions (sync stdin and stdout).
62fde24f 60+
bd67ca44 61This feature is mostly designed for interactive sessions. If the standard input is not a terminal, but for example a pipe (e.g., *echo "date" | runuser --pty -u* _user_), then the *ECHO* flag for the pseudo-terminal is disabled to avoid messy output.
a7574d88 62
a7574d88 63*-s*, *--shell*=_shell_::
62fde24f
MB
64Run the specified _shell_ instead of the default. The shell to run is selected according to the following rules, in order:
65
66* the shell specified with *--shell*
67* the shell specified in the environment variable *SHELL* if the *--preserve-environment* option is used
68* the shell listed in the passwd entry of the target user
69* /bin/sh
70+
71If the target user has a restricted shell (i.e., not listed in _/etc/shells_), then the *--shell* option and the *SHELL* environment variables are ignored unless the calling user is root.
a7574d88
MB
72
73**--session-command=**__command__::
62fde24f 74Same as *-c*, but do not create a new session. (Discouraged.)
a7574d88 75
2bc9cd09
SP
76*-T*, *--no-pty**::
77Do not create a pseudo-terminal, opposite of *--pty* and *-P*.
78Note that running without a pseudo-terminal opens the security risk of privilege escalation through TIOCSTI/TIOCLINUX ioctl command injection.
79
a7574d88 80*-w*, *--whitelist-environment*=_list_::
62fde24f 81Don't reset the environment variables specified in the comma-separated _list_ when clearing the environment for *--login*. The whitelist is ignored for the environment variables *HOME*, *SHELL*, *USER*, *LOGNAME*, and *PATH*.
a7574d88 82
2b2d3172 83include::man-common/help-version.adoc[]
a7574d88
MB
84
85== CONFIG FILES
86
87*runuser* reads the _/etc/default/runuser_ and _/etc/login.defs_ configuration files. The following configuration items are relevant for *runuser*:
88
62fde24f 89*ENV_PATH* (string)::
a7574d88 90Defines the PATH environment variable for a regular user. The default value is _/usr/local/bin:/bin:/usr/bin_.
a7574d88 91
62fde24f
MB
92*ENV_ROOTPATH* (string)::
93*ENV_SUPATH* (string)::
a7574d88 94Defines the *PATH* environment variable for root. *ENV_SUPATH* takes precedence. The default value is _/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin_.
a7574d88 95
62fde24f 96*ALWAYS_SET_PATH* (boolean)::
e6743239 97If set to _yes_ and *--login* and *--preserve-environment* were not specified *runuser* initializes *PATH*.
a7574d88
MB
98
99The environment variable *PATH* may be different on systems where _/bin_ and _/sbin_ are merged into _/usr_; this variable is also affected by the *--login* command-line option and the PAM system setting (e.g., *pam_env*(8)).
100
101== EXIT STATUS
102
103*runuser* normally returns the exit status of the command it executed. If the command was killed by a signal, *runuser* returns the number of the signal plus 128.
104
105Exit status generated by *runuser* itself:
106
a7574d88 1071::
62fde24f 108Generic error before executing the requested command
a7574d88 109126::
62fde24f 110The requested command could not be executed
a7574d88 111127::
62fde24f
MB
112The requested command was not found
113
a7574d88
MB
114
115== FILES
116
117_/etc/pam.d/runuser_::
62fde24f 118default PAM configuration file
a7574d88
MB
119
120_/etc/pam.d/runuser-l_::
62fde24f 121PAM configuration file if *--login* is specified
a7574d88
MB
122
123_/etc/default/runuser_::
62fde24f 124runuser specific logindef config file
a7574d88
MB
125
126_/etc/login.defs_::
62fde24f 127global logindef config file
a7574d88
MB
128
129== HISTORY
130
131This *runuser* command was derived from coreutils' *su*, which was based on an implementation by David MacKenzie, and the Fedora *runuser* command by Dan Walsh.
132
133== SEE ALSO
134
135*setpriv*(1),
136*su*(1),
137*login.defs*(5),
138*shells*(5),
139*pam*(8)
140
625e9c61 141include::man-common/bugreports.adoc[]
a7574d88 142
625e9c61 143include::man-common/footer.adoc[]
a7574d88
MB
144
145ifdef::translation[]
625e9c61 146include::man-common/translation.adoc[]
a7574d88 147endif::[]