]> git.ipfire.org Git - thirdparty/util-linux.git/blob - login-utils/runuser.1.adoc
fix whitespace issue in ducumentation
[thirdparty/util-linux.git] / login-utils / runuser.1.adoc
1 //po4a: entry man manual
2 = runuser(1)
3 :doctype: manpage
4 :man manual: User Commands
5 :man source: util-linux {release-version}
6 :page-layout: base
7 :command: runuser
8
9 == NAME
10
11 runuser - 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
23 If the PAM session is not required, then the recommended solution is to use the *setpriv*(1) command.
24
25 When called without arguments, *runuser* defaults to running an interactive shell as _root_.
26
27 For 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
29 Note 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
31 == OPTIONS
32
33 *-c*, *--command*=_command_::
34 Pass _command_ to the shell with the *-c* option.
35
36 *-f*, *--fast*::
37 Pass *-f* to the shell, which may or may not be useful, depending on the shell.
38
39 *-g*, *--group*=_group_::
40 The primary group to be used. This option is allowed for the root user only.
41
42 *-G*, *--supp-group*=_group_::
43 Specify 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.
44
45 *-*, *-l*, *--login*::
46 Start the shell as a login shell with an environment similar to a real login:
47 +
48 * clears all the environment variables except for *TERM* and variables specified by *--whitelist-environment*
49 * initializes the environment variables *HOME*, *SHELL*, *USER*, *LOGNAME*, and *PATH*
50 * changes to the target user's home directory
51 * sets argv[0] of the shell to '*-*' in order to make the shell a login shell
52
53 *-P*, *--pty*::
54 Create 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 (copy stdin and stdout).
55 +
56 This 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.
57
58 *-m*, *-p*, *--preserve-environment*::
59 Preserve the entire environment, i.e., do not set *HOME*, *SHELL*, *USER* or *LOGNAME*. The option is ignored if the option *--login* is specified.
60
61 *-s*, *--shell*=_shell_::
62 Run the specified _shell_ instead of the default. The shell to run is selected according to the following rules, in order:
63
64 * the shell specified with *--shell*
65 * the shell specified in the environment variable *SHELL* if the *--preserve-environment* option is used
66 * the shell listed in the passwd entry of the target user
67 * /bin/sh
68 +
69 If 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.
70
71 **--session-command=**__command__::
72 Same as *-c*, but do not create a new session. (Discouraged.)
73
74 *-w*, *--whitelist-environment*=_list_::
75 Don'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*.
76
77 *-V*, *--version*::
78 Display version information and exit.
79
80 *-h*, *--help*::
81 Display help text and exit.
82
83 == CONFIG FILES
84
85 *runuser* reads the _/etc/default/runuser_ and _/etc/login.defs_ configuration files. The following configuration items are relevant for *runuser*:
86
87 *ENV_PATH* (string)::
88 Defines the PATH environment variable for a regular user. The default value is _/usr/local/bin:/bin:/usr/bin_.
89
90 *ENV_ROOTPATH* (string)::
91 *ENV_SUPATH* (string)::
92 Defines 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_.
93
94 *ALWAYS_SET_PATH* (boolean)::
95 If set to _yes_ and --login and --preserve-environment were not specified *runuser* initializes *PATH*.
96
97 The 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)).
98
99 == EXIT STATUS
100
101 *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.
102
103 Exit status generated by *runuser* itself:
104
105 1::
106 Generic error before executing the requested command
107 126::
108 The requested command could not be executed
109 127::
110 The requested command was not found
111
112
113 == FILES
114
115 _/etc/pam.d/runuser_::
116 default PAM configuration file
117
118 _/etc/pam.d/runuser-l_::
119 PAM configuration file if *--login* is specified
120
121 _/etc/default/runuser_::
122 runuser specific logindef config file
123
124 _/etc/login.defs_::
125 global logindef config file
126
127 == HISTORY
128
129 This *runuser* command was derived from coreutils' *su*, which was based on an implementation by David MacKenzie, and the Fedora *runuser* command by Dan Walsh.
130
131 == SEE ALSO
132
133 *setpriv*(1),
134 *su*(1),
135 *login.defs*(5),
136 *shells*(5),
137 *pam*(8)
138
139 include::man-common/bugreports.adoc[]
140
141 include::man-common/footer.adoc[]
142
143 ifdef::translation[]
144 include::man-common/translation.adoc[]
145 endif::[]