'\" t .\" Title: runuser .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 .\" Date: 2024-03-20 .\" Manual: User Commands .\" Source: util-linux 2.40 .\" Language: English .\" .TH "RUNUSER" "1" "2024-03-20" "util\-linux 2.40" "User Commands" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" runuser \- run a command with substitute user and group ID .SH "SYNOPSIS" .sp \fBrunuser\fP [options] \fB\-u\fP \fIuser\fP [[\-\-] \fIcommand\fP [\fIargument\fP...]] .sp \fBrunuser\fP [options] [\fB\-\fP] [\fIuser\fP [\fIargument\fP...]] .SH "DESCRIPTION" .sp \fBrunuser\fP can be used to run commands with a substitute user and group ID. If the option \fB\-u\fP is not given, \fBrunuser\fP falls back to \fBsu\fP\-compatible semantics and a shell is executed. The difference between the commands \fBrunuser\fP and \fBsu\fP is that \fBrunuser\fP 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 \fBrunuser\fP does not have to be installed with set\-user\-ID permissions. .sp If the PAM session is not required, then the recommended solution is to use the \fBsetpriv\fP(1) command. .sp When called without arguments, \fBrunuser\fP defaults to running an interactive shell as \fIroot\fP. .sp For backward compatibility, \fBrunuser\fP defaults to not changing the current directory and to setting only the environment variables \fBHOME\fP and \fBSHELL\fP (plus \fBUSER\fP and \fBLOGNAME\fP if the target \fIuser\fP is not root). This version of \fBrunuser\fP uses PAM for session management. .sp Note that \fBrunuser\fP in all cases use PAM (pam_getenvlist()) to do the final environment modification. Command\-line options such as \fB\-\-login\fP and \fB\-\-preserve\-environment\fP affect the environment before it is modified by PAM. .sp Since version 2.38 \fBrunuser\fP resets process resource limits RLIMIT_NICE, RLIMIT_RTPRIO, RLIMIT_FSIZE, RLIMIT_AS and RLIMIT_NOFILE. .SH "OPTIONS" .sp \fB\-c\fP, \fB\-\-command\fP=\fIcommand\fP .RS 4 Pass \fIcommand\fP to the shell with the \fB\-c\fP option. .RE .sp \fB\-f\fP, \fB\-\-fast\fP .RS 4 Pass \fB\-f\fP to the shell, which may or may not be useful, depending on the shell. .RE .sp \fB\-g\fP, \fB\-\-group\fP=\fIgroup\fP .RS 4 The primary group to be used. This option is allowed for the root user only. .RE .sp \fB\-G\fP, \fB\-\-supp\-group\fP=\fIgroup\fP .RS 4 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 \fB\-\-group\fP is not specified. .RE .sp \fB\-\fP, \fB\-l\fP, \fB\-\-login\fP .RS 4 Start the shell as a login shell with an environment similar to a real login: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} clears all the environment variables except for \fBTERM\fP and variables specified by \fB\-\-whitelist\-environment\fP .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} initializes the environment variables \fBHOME\fP, \fBSHELL\fP, \fBUSER\fP, \fBLOGNAME\fP, and \fBPATH\fP .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} changes to the target user\(cqs home directory .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} sets argv[0] of the shell to \*(Aq\fB\-\fP\*(Aq in order to make the shell a login shell .RE .RE .sp \fB\-m\fP, \fB\-p\fP, \fB\-\-preserve\-environment\fP .RS 4 Preserve the entire environment, i.e., do not set \fBHOME\fP, \fBSHELL\fP, \fBUSER\fP or \fBLOGNAME\fP. The option is ignored if the option \fB\-\-login\fP is specified. .RE .sp \fB\-P\fP, \fB\-\-pty\fP .RS 4 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., \fBrunuser \-\-pty\fP \fB\-u\fP \fIusername\fP \fB\-\-\fP \fIcommand\fP \fB&\fP). If the pseudo\-terminal is enabled, then \fBrunuser\fP works as a proxy between the sessions (sync stdin and stdout). .sp This feature is mostly designed for interactive sessions. If the standard input is not a terminal, but for example a pipe (e.g., \fBecho "date" | runuser \-\-pty \-u\fP \fIuser\fP), then the \fBECHO\fP flag for the pseudo\-terminal is disabled to avoid messy output. .RE .sp \fB\-s\fP, \fB\-\-shell\fP=\fIshell\fP .RS 4 Run the specified \fIshell\fP instead of the default. The shell to run is selected according to the following rules, in order: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} the shell specified with \fB\-\-shell\fP .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} the shell specified in the environment variable \fBSHELL\fP if the \fB\-\-preserve\-environment\fP option is used .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} the shell listed in the passwd entry of the target user .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} /bin/sh .sp If the target user has a restricted shell (i.e., not listed in \fI/etc/shells\fP), then the \fB\-\-shell\fP option and the \fBSHELL\fP environment variables are ignored unless the calling user is root. .RE .RE .sp \fB\-\-session\-command=\fP\fIcommand\fP .RS 4 Same as \fB\-c\fP, but do not create a new session. (Discouraged.) .RE .sp \fB\-T\fP, \fB\-\-no\-pty\fP* .RS 4 Do not create a pseudo\-terminal, opposite of \fB\-\-pty\fP and \fB\-P\fP. Note that running without a pseudo\-terminal opens the security risk of privilege escalation through TIOCSTI/TIOCLINUX ioctl command injection. .RE .sp \fB\-w\fP, \fB\-\-whitelist\-environment\fP=\fIlist\fP .RS 4 Don\(cqt reset the environment variables specified in the comma\-separated \fIlist\fP when clearing the environment for \fB\-\-login\fP. The whitelist is ignored for the environment variables \fBHOME\fP, \fBSHELL\fP, \fBUSER\fP, \fBLOGNAME\fP, and \fBPATH\fP. .RE .sp \fB\-h\fP, \fB\-\-help\fP .RS 4 Display help text and exit. .RE .sp \fB\-V\fP, \fB\-\-version\fP .RS 4 Print version and exit. .RE .SH "CONFIG FILES" .sp \fBrunuser\fP reads the \fI/etc/default/runuser\fP and \fI/etc/login.defs\fP configuration files. The following configuration items are relevant for \fBrunuser\fP: .sp \fBENV_PATH\fP (string) .RS 4 Defines the PATH environment variable for a regular user. The default value is \fI/usr/local/bin:/bin:/usr/bin\fP. .RE .sp \fBENV_ROOTPATH\fP (string), \fBENV_SUPATH\fP (string) .RS 4 Defines the \fBPATH\fP environment variable for root. \fBENV_SUPATH\fP takes precedence. The default value is \fI/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin\fP. .RE .sp \fBALWAYS_SET_PATH\fP (boolean) .RS 4 If set to \fIyes\fP and \fB\-\-login\fP and \fB\-\-preserve\-environment\fP were not specified \fBrunuser\fP initializes \fBPATH\fP. .RE .sp The environment variable \fBPATH\fP may be different on systems where \fI/bin\fP and \fI/sbin\fP are merged into \fI/usr\fP; this variable is also affected by the \fB\-\-login\fP command\-line option and the PAM system setting (e.g., \fBpam_env\fP(8)). .SH "EXIT STATUS" .sp \fBrunuser\fP normally returns the exit status of the command it executed. If the command was killed by a signal, \fBrunuser\fP returns the number of the signal plus 128. .sp Exit status generated by \fBrunuser\fP itself: .sp 1 .RS 4 Generic error before executing the requested command .RE .sp 126 .RS 4 The requested command could not be executed .RE .sp 127 .RS 4 The requested command was not found .RE .SH "FILES" .sp \fI/etc/pam.d/runuser\fP .RS 4 default PAM configuration file .RE .sp \fI/etc/pam.d/runuser\-l\fP .RS 4 PAM configuration file if \fB\-\-login\fP is specified .RE .sp \fI/etc/default/runuser\fP .RS 4 runuser specific logindef config file .RE .sp \fI/etc/login.defs\fP .RS 4 global logindef config file .RE .SH "HISTORY" .sp This \fBrunuser\fP command was derived from coreutils\*(Aq \fBsu\fP, which was based on an implementation by David MacKenzie, and the Fedora \fBrunuser\fP command by Dan Walsh. .SH "SEE ALSO" .sp \fBsetpriv\fP(1), \fBsu\fP(1), \fBlogin.defs\fP(5), \fBshells\fP(5), \fBpam\fP(8) .SH "REPORTING BUGS" .sp For bug reports, use the issue tracker at \c .URL "https://github.com/util\-linux/util\-linux/issues" "" "." .SH "AVAILABILITY" .sp The \fBrunuser\fP command is part of the util\-linux package which can be downloaded from \c .URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "."