diff options
Diffstat (limited to 'login-utils/su.1')
-rw-r--r-- | login-utils/su.1 | 299 |
1 files changed, 299 insertions, 0 deletions
diff --git a/login-utils/su.1 b/login-utils/su.1 new file mode 100644 index 0000000..dbb1f7d --- /dev/null +++ b/login-utils/su.1 @@ -0,0 +1,299 @@ +'\" t +.\" Title: su +.\" Author: [see the "AUTHOR(S)" section] +.\" Generator: Asciidoctor 2.0.15 +.\" Date: 2022-05-11 +.\" Manual: User Commands +.\" Source: util-linux 2.38.1 +.\" Language: English +.\" +.TH "SU" "1" "2022-05-11" "util\-linux 2.38.1" "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" +su \- run a command with substitute user and group ID +.SH "SYNOPSIS" +.sp +\fBsu\fP [options] [\fB\-\fP] [\fIuser\fP [\fIargument\fP...]] +.SH "DESCRIPTION" +.sp +\fBsu\fP allows commands to be run with a substitute user and group ID. +.sp +When called with no \fIuser\fP specified, \fBsu\fP defaults to running an interactive shell as \fIroot\fP. When \fIuser\fP is specified, additional \fIargument\fPs can be supplied, in which case they are passed to the shell. +.sp +For backward compatibility, \fBsu\fP defaults to not change the current directory and to only set the environment variables \fBHOME\fP and \fBSHELL\fP (plus \fBUSER\fP and \fBLOGNAME\fP if the target \fIuser\fP is not root). It is recommended to always use the \fB\-\-login\fP option (instead of its shortcut \fB\-\fP) to avoid side effects caused by mixing environments. +.sp +This version of \fBsu\fP uses PAM for authentication, account and session management. Some configuration options found in other \fBsu\fP implementations, such as support for a wheel group, have to be configured via PAM. +.sp +\fBsu\fP is mostly designed for unprivileged users, the recommended solution for privileged users (e.g., scripts executed by root) is to use non\-set\-user\-ID command \fBrunuser\fP(1) that does not require authentication and provides separate PAM configuration. If the PAM session is not required at all then the recommended solution is to use command \fBsetpriv\fP(1). +.sp +Note that \fBsu\fP in all cases uses PAM (\fBpam_getenvlist\fP(3)) 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 \fBsu\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 +Specify the primary group. This option is available to 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 \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. This 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 \fBTIOCSTI\fP ioctl terminal injection and other security attacks against terminal file descriptors. The entire session can also be moved to the background (e.g., \fBsu \-\-pty\fP \fB\-\fP \fIusername\fP \fB\-c\fP \fIapplication\fP \fB&\fP). If the pseudo\-terminal is enabled, then \fBsu\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" | su \-\-pty\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 +.RE +.RE +.sp +If the target user has a restricted shell (i.e., not listed in \fI/etc/shells\fP), the \fB\-\-shell\fP option and the \fBSHELL\fP environment variables are ignored unless the calling user is root. +.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\-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 "SIGNALS" +.sp +Upon receiving either \fBSIGINT\fP, \fBSIGQUIT\fP or \fBSIGTERM\fP, \fBsu\fP terminates its child and afterwards terminates itself with the received signal. The child is terminated by \fBSIGTERM\fP, after unsuccessful attempt and 2 seconds of delay the child is killed by \fBSIGKILL\fP. +.SH "CONFIG FILES" +.sp +\fBsu\fP reads the \fI/etc/default/su\fP and \fI/etc/login.defs\fP configuration files. The following configuration items are relevant for \fBsu\fP: +.sp +\fBFAIL_DELAY\fP (number) +.RS 4 +Delay in seconds in case of an authentication failure. The number must be a non\-negative integer. +.RE +.sp +\fBENV_PATH\fP (string) +.RS 4 +Defines the \fBPATH\fP 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 \fBsu\fP initializes \fBPATH\fP. +.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)). +.RE +.SH "EXIT STATUS" +.sp +\fBsu\fP normally returns the exit status of the command it executed. If the command was killed by a signal, \fBsu\fP returns the number of the signal plus 128. +.sp +Exit status generated by \fBsu\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/su\fP +.RS 4 +default PAM configuration file +.RE +.sp +\fI/etc/pam.d/su\-l\fP +.RS 4 +PAM configuration file if \fB\-\-login\fP is specified +.RE +.sp +\fI/etc/default/su\fP +.RS 4 +command specific logindef config file +.RE +.sp +\fI/etc/login.defs\fP +.RS 4 +global logindef config file +.RE +.SH "NOTES" +.sp +For security reasons, \fBsu\fP always logs failed log\-in attempts to the \fIbtmp\fP file, but it does not write to the \fIlastlog\fP file at all. This solution can be used to control \fBsu\fP behavior by PAM configuration. If you want to use the \fBpam_lastlog\fP(8) module to print warning message about failed log\-in attempts then \fBpam_lastlog\fP(8) has to be configured to update the \fIlastlog\fP file as well. For example by: +.RS 3 +.ll -.6i +.sp +session required pam_lastlog.so nowtmp +.br +.RE +.ll +.SH "HISTORY" +.sp +This \fBsu\fP command was derived from coreutils\(aq \fBsu\fP, which was based on an implementation by David MacKenzie. The util\-linux version has been refactored by Karel Zak. +.SH "SEE ALSO" +.sp +\fBsetpriv\fP(1), +\fBlogin.defs\fP(5), +\fBshells\fP(5), +\fBpam\fP(8), +\fBrunuser\fP(1) +.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 \fBsu\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" "."
\ No newline at end of file |