]> git.ipfire.org Git - thirdparty/util-linux.git/blame - login-utils/su.1
docs: improve grammar and consistency of comments in login.c
[thirdparty/util-linux.git] / login-utils / su.1
CommitLineData
2ab15cb0 1.TH SU "1" "June 2012" "util-linux" "User Commands"
8d581640 2.SH NAME
2ab15cb0 3su \- run a command with substitute user and group ID
8d581640
SK
4.SH SYNOPSIS
5.B su
2ab15cb0 6[options...] [\-] [user [args...]]
8d581640
SK
7.SH DESCRIPTION
8.B su
2ab15cb0 9allows to run commands with substitute user and group ID.
8d581640 10.PP
2ab15cb0 11When called without arguments
8d581640 12.B su
2ab15cb0
LN
13defaults to running an interactive shell as
14.IR root .
8d581640 15.PP
22b49b33 16For backward compatibility
8d581640 17.B su
2ab15cb0 18defaults to not change the current directory and to only set the
7007991f 19environment variables
2ab15cb0
LN
20.B HOME
21and
22.B SHELL
23(plus
24.B USER
25and
26.B LOGNAME
27if the target
28.I user
29is not root). It is recommended to always use the
30.B \-\-login
31option (instead it's shortcut
32.BR \- )
33to avoid side effects caused by mixing environments.
8d581640 34.PP
2ab15cb0 35This version of
8d581640 36.B su
2ab15cb0
LN
37uses PAM for authentication, account and session management. Some
38configuration options found in other
8d581640 39.B su
2ab15cb0
LN
40implementations such as e.g. support of a wheel group have to be
41configured via PAM.
8d581640
SK
42.SH OPTIONS
43.TP
2ab15cb0
LN
44\fB\-c\fR \fIcommand\fR, \fB\-\-command\fR=\fIcommand\fR
45Pass
46.I command
47to the shell with the
48.B \-c
49option.
50.TP
51\fB\-\-session\-command\fR=\fIcommand\fR
52Same as
53.B \-c
54but do not create a new session (discouraged).
8d581640
SK
55.TP
56\fB\-f\fR, \fB\-\-fast\fR
2ab15cb0
LN
57Pass
58.B \-f
59to the shell which may or may not be useful depending on the
60shell.
8d581640 61.TP
8528ea2f
KZ
62\fB\-g\fR, \fB\-\-group\fR=\fIgroup\fR\fR
63specify the primary group, this option is allowed for root user only
64.TP
65\fB\-G\fR, \fB\-\-supp-group\fR=\fIgroup\fR\fR
66specify a supplemental group, this option is allowed for root user only
67.TP
8d581640 68\fB\-\fR, \fB\-l\fR, \fB\-\-login\fR
2ab15cb0
LN
69Starts the shell as login shell with an environment similar to a real
70login:
71.RS 10
8d581640 72.TP
2ab15cb0
LN
73o
74clears all environment variables except for
75.B TERM
76.TP
77o
78initializes the environment variables
79.BR HOME ,
80.BR SHELL ,
81.BR USER ,
82.BR LOGNAME ,
83.B PATH
84.TP
85o
86changes to the target user's home directory
87.TP
88o
89sets argv[0] of the shell to
90.RB ' \- '
91in order to make the shell a login shell
92.RE
93.TP
94\fB\-m\fR, \fB\-p\fR, \fB\-\-preserve-environment\fR
95Preserves the whole environment, ie does not set
96.BR HOME ,
97.BR SHELL ,
98.B USER
99nor
100.BR LOGNAME .
3e5c0a2d 101The option is ignored if the option \fB\-\-login\fR is specified.
2ab15cb0
LN
102.TP
103\fB\-s\fR \fISHELL\fR, \fB\-\-shell\fR=\fISHELL\fR
104Runs the specified shell instead of the default. The shell to run is
105selected according to the following rules in order:
106.RS 10
107.TP
108o
109the shell specified with
110.B \-\-shell
111.TP
112o
113The shell specified in the environment variable
114.B SHELL
115if the
116.B \-\-preserve-environment
117option is used.
8d581640 118.TP
2ab15cb0
LN
119o
120the shell listed in the passwd entry of the target user
8d581640 121.TP
2ab15cb0
LN
122o
123/bin/sh
124.RE
125.IP
126If the target user has a restricted shell (i.e. not listed in
127/etc/shells) the
128.B \-\-shell
129option and the
130.B SHELL
131environment variables are ignored unless the calling user is root.
132.TP
133\fB\-\-help\fR
134Display help text and exit.
8d581640 135.TP
2ab15cb0
LN
136\fB\-\-version\fR
137Display version information and exit.
138.SH CONFIG FILES
139.B su
140reads the
141.I /etc/default/su
142and
143.I /etc/login.defs
144configuration files. The following configuration items are relevant
145for
146.BR su (1):
147.PP
148.B FAIL_DELAY
149(number)
150.RS 4
151Delay in seconds in case of authentication failure. Number must be
152a non-negative integer.
153.RE
154.PP
155.B ENV_PATH
156(string)
157.RS 4
158Defines the PATH environment variable for a regular user. The
159default value is
160.IR /usr/local/bin:\:/bin:\:/usr/bin .
161.RE
162.PP
163.B ENV_ROOTPATH
164(string)
8d581640 165.br
2ab15cb0
LN
166.B ENV_SUPATH
167(string)
168.RS 4
169Defines the PATH environment variable for root. The default value is
170.IR /usr/local/sbin:\:/usr/local/bin:\:/sbin:\:/bin:\:/usr/sbin:\:/usr/bin .
171.RE
172.PP
173.B ALWAYS_SET_PATH
174(boolean)
175.RS 4
176If set to
177.I yes
178and \-\-login and \-\-preserve\-environment were not specified
8d581640 179.B su
2ab15cb0
LN
180initializes
181.BR PATH .
182.RE
183.SH EXIT STATUS
184.B su
185normally returns the exit status of the command it executed. If the
186command was killed by a signal,
187.B su
188returns the number of the signal plus 128.
8d581640 189.PP
2ab15cb0
LN
190Exit status generated by
191.B su
192itself:
193.RS 10
8d581640 194.TP
2ab15cb0
LN
1951
196Generic error before executing the requested command
8d581640 197.TP
2ab15cb0
LN
198126
199The requested command could not be executed
8d581640 200.TP
2ab15cb0
LN
201127
202The requested command could was not found
8d581640
SK
203.RE
204.SH FILES
2ab15cb0
LN
205.PD 0
206.TP 17
207/etc/pam.d/su
208default PAM configuration file
8d581640 209.TP
2ab15cb0
LN
210/etc/pam.d/su-l
211PAM configuration file if \-\-login is specified
212.TP
213/etc/default/su
22b49b33 214command specific logindef config file
2ab15cb0
LN
215.TP
216/etc/login.defs
22b49b33 217global logindef config file
2ab15cb0 218.PD 1
8d581640 219.SH "SEE ALSO"
7a7f9d38 220.BR runuser (8),
2ab15cb0
LN
221.BR pam (8),
222.BR shells (5),
22b49b33 223.BR login.defs (5)
2ab15cb0 224.SH AUTHOR
22b49b33 225Derived from coreutils' su which was based on an implementation from
2ab15cb0 226David MacKenzie.
8d581640 227.SH AVAILABILITY
22b49b33 228The su command is part of the util-linux package and is
8d581640
SK
229available from
230.UR ftp://\:ftp.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
231Linux Kernel Archive
232.UE .