update Debian standards version
[debian/sudo] / sudo.man.in
1 .\" Copyright (c) 1994-1996, 1998-2005, 2007-2009
2 .\"     Todd C. Miller <Todd.Miller@courtesan.com>
3 .\" 
4 .\" Permission to use, copy, modify, and distribute this software for any
5 .\" purpose with or without fee is hereby granted, provided that the above
6 .\" copyright notice and this permission notice appear in all copies.
7 .\" 
8 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 .\" 
17 .\" Sponsored in part by the Defense Advanced Research Projects
18 .\" Agency (DARPA) and Air Force Research Laboratory, Air Force
19 .\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
20 .\" 
21 .\" $Sudo: sudo.pod,v 1.125 2009/09/25 00:31:35 millert Exp $
22 .\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.07)
23 .\"
24 .\" Standard preamble:
25 .\" ========================================================================
26 .de Sp \" Vertical space (when we can't use .PP)
27 .if t .sp .5v
28 .if n .sp
29 ..
30 .de Vb \" Begin verbatim text
31 .ft CW
32 .nf
33 .ne \\$1
34 ..
35 .de Ve \" End verbatim text
36 .ft R
37 .fi
38 ..
39 .\" Set up some character translations and predefined strings.  \*(-- will
40 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
41 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
42 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
43 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
44 .\" nothing in troff, for use with C<>.
45 .tr \(*W-
46 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
47 .ie n \{\
48 .    ds -- \(*W-
49 .    ds PI pi
50 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
51 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
52 .    ds L" ""
53 .    ds R" ""
54 .    ds C` 
55 .    ds C' 
56 'br\}
57 .el\{\
58 .    ds -- \|\(em\|
59 .    ds PI \(*p
60 .    ds L" ``
61 .    ds R" ''
62 'br\}
63 .\"
64 .\" Escape single quotes in literal strings from groff's Unicode transform.
65 .ie \n(.g .ds Aq \(aq
66 .el       .ds Aq '
67 .\"
68 .\" If the F register is turned on, we'll generate index entries on stderr for
69 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
70 .\" entries marked with X<> in POD.  Of course, you'll have to process the
71 .\" output yourself in some meaningful fashion.
72 .ie \nF \{\
73 .    de IX
74 .    tm Index:\\$1\t\\n%\t"\\$2"
75 ..
76 .    nr % 0
77 .    rr F
78 .\}
79 .el \{\
80 .    de IX
81 ..
82 .\}
83 .\"
84 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
85 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
86 .    \" fudge factors for nroff and troff
87 .if n \{\
88 .    ds #H 0
89 .    ds #V .8m
90 .    ds #F .3m
91 .    ds #[ \f1
92 .    ds #] \fP
93 .\}
94 .if t \{\
95 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
96 .    ds #V .6m
97 .    ds #F 0
98 .    ds #[ \&
99 .    ds #] \&
100 .\}
101 .    \" simple accents for nroff and troff
102 .if n \{\
103 .    ds ' \&
104 .    ds ` \&
105 .    ds ^ \&
106 .    ds , \&
107 .    ds ~ ~
108 .    ds /
109 .\}
110 .if t \{\
111 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
112 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
113 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
114 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
115 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
116 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
117 .\}
118 .    \" troff and (daisy-wheel) nroff accents
119 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
120 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
121 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
122 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
123 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
124 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
125 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
126 .ds ae a\h'-(\w'a'u*4/10)'e
127 .ds Ae A\h'-(\w'A'u*4/10)'E
128 .    \" corrections for vroff
129 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
130 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
131 .    \" for low resolution devices (crt and lpr)
132 .if \n(.H>23 .if \n(.V>19 \
133 \{\
134 .    ds : e
135 .    ds 8 ss
136 .    ds o a
137 .    ds d- d\h'-1'\(ga
138 .    ds D- D\h'-1'\(hy
139 .    ds th \o'bp'
140 .    ds Th \o'LP'
141 .    ds ae ae
142 .    ds Ae AE
143 .\}
144 .rm #[ #] #H #V #F C
145 .\" ========================================================================
146 .\"
147 .IX Title "SUDO @mansectsu@"
148 .TH SUDO @mansectsu@ "February 22, 2010" "1.7.2p5" "MAINTENANCE COMMANDS"
149 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
150 .\" way too many mistakes in technical documents.
151 .if n .ad l
152 .nh
153 .SH "NAME"
154 sudo, sudoedit \- execute a command as another user
155 .SH "SYNOPSIS"
156 .IX Header "SYNOPSIS"
157 \&\fBsudo\fR \fB\-h\fR | \fB\-K\fR | \fB\-k\fR | \fB\-L\fR | \fB\-V\fR
158 .PP
159 \&\fBsudo\fR \fB\-v\fR [\fB\-AknS\fR]
160 @BAMAN@[\fB\-a\fR\ \fIauth_type\fR]
161 [\fB\-p\fR\ \fIprompt\fR]
162 .PP
163 \&\fBsudo\fR \fB\-l[l]\fR [\fB\-AknS\fR]
164 @BAMAN@[\fB\-a\fR\ \fIauth_type\fR]
165 [\fB\-g\fR\ \fIgroupname\fR|\fI#gid\fR] [\fB\-p\fR\ \fIprompt\fR]
166 [\fB\-U\fR\ \fIusername\fR] [\fB\-u\fR\ \fIusername\fR|\fI#uid\fR] [\fIcommand\fR]
167 .PP
168 \&\fBsudo\fR [\fB\-AbEHnPS\fR]
169 @BAMAN@[\fB\-a\fR\ \fIauth_type\fR]
170 [\fB\-C\fR\ \fIfd\fR]
171 @LCMAN@[\fB\-c\fR\ \fIclass\fR|\fI\-\fR]
172 [\fB\-g\fR\ \fIgroupname\fR|\fI#gid\fR] [\fB\-p\fR\ \fIprompt\fR]
173 @SEMAN@[\fB\-r\fR\ \fIrole\fR] [\fB\-t\fR\ \fItype\fR]
174 [\fB\-u\fR\ \fIusername\fR|\fI#uid\fR]
175 [\fB\s-1VAR\s0\fR=\fIvalue\fR] [\fB\-i\fR\ |\ \fB\-s\fR] [\fIcommand\fR]
176 .PP
177 \&\fBsudoedit\fR [\fB\-AnS\fR]
178 @BAMAN@[\fB\-a\fR\ \fIauth_type\fR]
179 [\fB\-C\fR\ \fIfd\fR]
180 @LCMAN@[\fB\-c\fR\ \fIclass\fR|\fI\-\fR]
181 [\fB\-g\fR\ \fIgroupname\fR|\fI#gid\fR] [\fB\-p\fR\ \fIprompt\fR]
182 [\fB\-u\fR\ \fIusername\fR|\fI#uid\fR] file ...
183 .SH "DESCRIPTION"
184 .IX Header "DESCRIPTION"
185 \&\fBsudo\fR allows a permitted user to execute a \fIcommand\fR as the
186 superuser or another user, as specified in the \fIsudoers\fR file.
187 The real and effective uid and gid are set to match those of the
188 target user as specified in the passwd file and the group vector
189 is initialized based on the group file (unless the \fB\-P\fR option was
190 specified).  If the invoking user is root or if the target user is
191 the same as the invoking user, no password is required.  Otherwise,
192 \&\fBsudo\fR requires that users authenticate themselves with a password
193 by default (\s-1NOTE:\s0 in the default configuration this is the user's
194 password, not the root password).  Once a user has been authenticated,
195 a timestamp is updated and the user may then use sudo without a
196 password for a short period of time (\f(CW\*(C`@timeout@\*(C'\fR minutes unless
197 overridden in \fIsudoers\fR).
198 .PP
199 When invoked as \fBsudoedit\fR, the \fB\-e\fR option (described below),
200 is implied.
201 .PP
202 \&\fBsudo\fR determines who is an authorized user by consulting the file
203 \&\fI@sysconfdir@/sudoers\fR.  By running \fBsudo\fR with the \fB\-v\fR option,
204 a user can update the time stamp without running a \fIcommand\fR. The
205 password prompt itself will also time out if the user's password
206 is not entered within \f(CW\*(C`@password_timeout@\*(C'\fR minutes (unless overridden
207 via \fIsudoers\fR).
208 .PP
209 If a user who is not listed in the \fIsudoers\fR file tries to run a
210 command via \fBsudo\fR, mail is sent to the proper authorities, as
211 defined at configure time or in the \fIsudoers\fR file (defaults to
212 \&\f(CW\*(C`@mailto@\*(C'\fR).  Note that the mail will not be sent if an unauthorized
213 user tries to run sudo with the \fB\-l\fR or \fB\-v\fR option.  This allows
214 users to determine for themselves whether or not they are allowed
215 to use \fBsudo\fR.
216 .PP
217 If \fBsudo\fR is run by root and the \f(CW\*(C`SUDO_USER\*(C'\fR environment variable
218 is set, \fBsudo\fR will use this value to determine who the actual
219 user is.  This can be used by a user to log commands through sudo
220 even when a root shell has been invoked.  It also allows the \fB\-e\fR
221 option to remain useful even when being run via a sudo-run script or
222 program.  Note however, that the sudoers lookup is still done for
223 root, not the user specified by \f(CW\*(C`SUDO_USER\*(C'\fR.
224 .PP
225 \&\fBsudo\fR can log both successful and unsuccessful attempts (as well
226 as errors) to \fIsyslog\fR\|(3), a log file, or both.  By default \fBsudo\fR
227 will log via \fIsyslog\fR\|(3) but this is changeable at configure time
228 or via the \fIsudoers\fR file.
229 .SH "OPTIONS"
230 .IX Header "OPTIONS"
231 \&\fBsudo\fR accepts the following command line options:
232 .IP "\-A" 12
233 .IX Item "-A"
234 Normally, if \fBsudo\fR requires a password, it will read it from the
235 current terminal.  If the \fB\-A\fR (\fIaskpass\fR) option is specified,
236 a (possibly graphical) helper program is executed to read the
237 user's password and output the password to the standard output.  If
238 the \f(CW\*(C`SUDO_ASKPASS\*(C'\fR environment variable is set, it specifies the
239 path to the helper program.  Otherwise, the value specified by the
240 \&\fIaskpass\fR option in \fIsudoers\fR\|(@mansectform@) is used.
241 @BAMAN@.IP "\-a \fItype\fR" 12
242 @BAMAN@.IX Item "-a type"
243 @BAMAN@The \fB\-a\fR (\fIauthentication type\fR) option causes \fBsudo\fR to use the
244 @BAMAN@specified authentication type when validating the user, as allowed
245 @BAMAN@by \fI/etc/login.conf\fR.  The system administrator may specify a list
246 @BAMAN@of sudo-specific authentication methods by adding an \*(L"auth-sudo\*(R"
247 @BAMAN@entry in \fI/etc/login.conf\fR.  This option is only available on systems
248 @BAMAN@that support \s-1BSD\s0 authentication.
249 .IP "\-b" 12
250 .IX Item "-b"
251 The \fB\-b\fR (\fIbackground\fR) option tells \fBsudo\fR to run the given
252 command in the background.  Note that if you use the \fB\-b\fR
253 option you cannot use shell job control to manipulate the process.
254 .IP "\-C \fIfd\fR" 12
255 .IX Item "-C fd"
256 Normally, \fBsudo\fR will close all open file descriptors other than
257 standard input, standard output and standard error.  The \fB\-C\fR
258 (\fIclose from\fR) option allows the user to specify a starting point
259 above the standard error (file descriptor three).  Values less than
260 three are not permitted.  This option is only available if the
261 administrator has enabled the \fIclosefrom_override\fR option in
262 \&\fIsudoers\fR\|(@mansectform@).
263 @LCMAN@.IP "\-c \fIclass\fR" 12
264 @LCMAN@.IX Item "-c class"
265 @LCMAN@The \fB\-c\fR (\fIclass\fR) option causes \fBsudo\fR to run the specified command
266 @LCMAN@with resources limited by the specified login class.  The \fIclass\fR
267 @LCMAN@argument can be either a class name as defined in \fI/etc/login.conf\fR,
268 @LCMAN@or a single '\-' character.  Specifying a \fIclass\fR of \f(CW\*(C`\-\*(C'\fR indicates
269 @LCMAN@that the command should be run restricted by the default login
270 @LCMAN@capabilities for the user the command is run as.  If the \fIclass\fR
271 @LCMAN@argument specifies an existing user class, the command must be run
272 @LCMAN@as root, or the \fBsudo\fR command must be run from a shell that is already
273 @LCMAN@root.  This option is only available on systems with \s-1BSD\s0 login classes.
274 .IP "\-E" 12
275 .IX Item "-E"
276 The \fB\-E\fR (\fIpreserve\fR \fIenvironment\fR) option will override the
277 \&\fIenv_reset\fR option in \fIsudoers\fR\|(@mansectform@)).  It is only
278 available when either the matching command has the \f(CW\*(C`SETENV\*(C'\fR tag
279 or the \fIsetenv\fR option is set in \fIsudoers\fR\|(@mansectform@).
280 .IP "\-e" 12
281 .IX Item "-e"
282 The \fB\-e\fR (\fIedit\fR) option indicates that, instead of running
283 a command, the user wishes to edit one or more files.  In lieu
284 of a command, the string \*(L"sudoedit\*(R" is used when consulting
285 the \fIsudoers\fR file.  If the user is authorized by \fIsudoers\fR
286 the following steps are taken:
287 .RS 12
288 .IP "1." 4
289 Temporary copies are made of the files to be edited with the owner
290 set to the invoking user.
291 .IP "2." 4
292 The editor specified by the \f(CW\*(C`SUDO_EDITOR\*(C'\fR, \f(CW\*(C`VISUAL\*(C'\fR or \f(CW\*(C`EDITOR\*(C'\fR
293 environment variables is run to edit the temporary files.  If none
294 of \f(CW\*(C`SUDO_EDITOR\*(C'\fR, \f(CW\*(C`VISUAL\*(C'\fR or \f(CW\*(C`EDITOR\*(C'\fR are set, the first program
295 listed in the \fIeditor\fR \fIsudoers\fR variable is used.
296 .IP "3." 4
297 If they have been modified, the temporary files are copied back to
298 their original location and the temporary versions are removed.
299 .RE
300 .RS 12
301 .Sp
302 If the specified file does not exist, it will be created.  Note
303 that unlike most commands run by \fBsudo\fR, the editor is run with
304 the invoking user's environment unmodified.  If, for some reason,
305 \&\fBsudo\fR is unable to update a file with its edited version, the
306 user will receive a warning and the edited copy will remain in a
307 temporary file.
308 .RE
309 .IP "\-g \fIgroup\fR" 12
310 .IX Item "-g group"
311 Normally, \fBsudo\fR sets the primary group to the one specified by
312 the passwd database for the user the command is being run as (by
313 default, root).  The \fB\-g\fR (\fIgroup\fR) option causes \fBsudo\fR to run
314 the specified command with the primary group set to \fIgroup\fR.  To
315 specify a \fIgid\fR instead of a \fIgroup name\fR, use \fI#gid\fR.  When
316 running commands as a \fIgid\fR, many shells require that the '#' be
317 escaped with a backslash ('\e').  If no \fB\-u\fR option is specified,
318 the command will be run as the invoking user (not root).  In either
319 case, the primary group will be set to \fIgroup\fR.
320 .IP "\-H" 12
321 .IX Item "-H"
322 The \fB\-H\fR (\fI\s-1HOME\s0\fR) option sets the \f(CW\*(C`HOME\*(C'\fR environment variable
323 to the homedir of the target user (root by default) as specified
324 in \fIpasswd\fR\|(@mansectform@).  By default, \fBsudo\fR does not modify \f(CW\*(C`HOME\*(C'\fR
325 (see \fIset_home\fR and \fIalways_set_home\fR in \fIsudoers\fR\|(@mansectform@)).
326 .IP "\-h" 12
327 .IX Item "-h"
328 The \fB\-h\fR (\fIhelp\fR) option causes \fBsudo\fR to print a usage message and exit.
329 .IP "\-i [command]" 12
330 .IX Item "-i [command]"
331 The \fB\-i\fR (\fIsimulate initial login\fR) option runs the shell specified
332 in the \fIpasswd\fR\|(@mansectform@) entry of the target user as a login shell.  This
333 means that login-specific resource files such as \f(CW\*(C`.profile\*(C'\fR or
334 \&\f(CW\*(C`.login\*(C'\fR will be read by the shell.  If a command is specified,
335 it is passed to the shell for execution.  Otherwise, an interactive
336 shell is executed.  \fBsudo\fR attempts to change to that user's home
337 directory before running the shell.  It also initializes the
338 environment, leaving \fI\s-1DISPLAY\s0\fR and \fI\s-1TERM\s0\fR unchanged, setting
339 \&\fI\s-1HOME\s0\fR, \fI\s-1SHELL\s0\fR, \fI\s-1USER\s0\fR, \fI\s-1LOGNAME\s0\fR, and \fI\s-1PATH\s0\fR, as well as
340 the contents of \fI/etc/environment\fR on Linux and \s-1AIX\s0 systems.
341 All other environment variables are removed.
342 .IP "\-K" 12
343 .IX Item "-K"
344 The \fB\-K\fR (sure \fIkill\fR) option is like \fB\-k\fR except that it removes
345 the user's timestamp entirely and may not be used in conjunction
346 with a command or other option.  This option does not require a
347 password.
348 .IP "\-k" 12
349 .IX Item "-k"
350 When used by itself, the \fB\-k\fR (\fIkill\fR) option to \fBsudo\fR invalidates
351 the user's timestamp by setting the time on it to the Epoch.  The
352 next time \fBsudo\fR is run a password will be required.  This option
353 does not require a password and was added to allow a user to revoke
354 \&\fBsudo\fR permissions from a .logout file.
355 .Sp
356 When used in conjunction with a command or an option that may require
357 a password, the \fB\-k\fR option will cause \fBsudo\fR to ignore the user's
358 timestamp file.  As a result, \fBsudo\fR will prompt for a password
359 (if one is required by \fIsudoers\fR) and will not update the user's
360 timestamp file.
361 .IP "\-L" 12
362 .IX Item "-L"
363 The \fB\-L\fR (\fIlist\fR defaults) option will list out the parameters
364 that may be set in a \fIDefaults\fR line along with a short description
365 for each.  This option is useful in conjunction with \fIgrep\fR\|(1).
366 .IP "\-l[l] [\fIcommand\fR]" 12
367 .IX Item "-l[l] [command]"
368 If no \fIcommand\fR is specified, the \fB\-l\fR (\fIlist\fR) option will list
369 the allowed (and forbidden) commands for the invoking user (or the
370 user specified by the \fB\-U\fR option) on the current host.  If a
371 \&\fIcommand\fR is specified and is permitted by \fIsudoers\fR, the
372 fully-qualified path to the command is displayed along with any
373 command line arguments.  If \fIcommand\fR is specified but not allowed,
374 \&\fBsudo\fR will exit with a status value of 1.  If the \fB\-l\fR option is
375 specified with an \fBl\fR argument (i.e. \fB\-ll\fR), or if \fB\-l\fR
376 is specified multiple times, a longer list format is used.
377 .IP "\-n" 12
378 .IX Item "-n"
379 The \fB\-n\fR (\fInon-interactive\fR) option prevents \fBsudo\fR from prompting
380 the user for a password.  If a password is required for the command
381 to run, \fBsudo\fR will display an error messages and exit.
382 .IP "\-P" 12
383 .IX Item "-P"
384 The \fB\-P\fR (\fIpreserve\fR \fIgroup vector\fR) option causes \fBsudo\fR to
385 preserve the invoking user's group vector unaltered.  By default,
386 \&\fBsudo\fR will initialize the group vector to the list of groups the
387 target user is in.  The real and effective group IDs, however, are
388 still set to match the target user.
389 .IP "\-p \fIprompt\fR" 12
390 .IX Item "-p prompt"
391 The \fB\-p\fR (\fIprompt\fR) option allows you to override the default
392 password prompt and use a custom one.  The following percent (`\f(CW\*(C`%\*(C'\fR')
393 escapes are supported:
394 .RS 12
395 .ie n .IP "%H" 4
396 .el .IP "\f(CW%H\fR" 4
397 .IX Item "%H"
398 expanded to the local hostname including the domain name
399 (on if the machine's hostname is fully qualified or the \fIfqdn\fR
400 \&\fIsudoers\fR option is set)
401 .ie n .IP "%h" 4
402 .el .IP "\f(CW%h\fR" 4
403 .IX Item "%h"
404 expanded to the local hostname without the domain name
405 .ie n .IP "%p" 4
406 .el .IP "\f(CW%p\fR" 4
407 .IX Item "%p"
408 expanded to the user whose password is being asked for (respects the
409 \&\fIrootpw\fR, \fItargetpw\fR and \fIrunaspw\fR flags in \fIsudoers\fR)
410 .ie n .IP "%U" 4
411 .el .IP "\f(CW%U\fR" 4
412 .IX Item "%U"
413 expanded to the login name of the user the command will
414 be run as (defaults to root)
415 .ie n .IP "%u" 4
416 .el .IP "\f(CW%u\fR" 4
417 .IX Item "%u"
418 expanded to the invoking user's login name
419 .ie n .IP "\*(C`%%\*(C'" 4
420 .el .IP "\f(CW\*(C`%%\*(C'\fR" 4
421 .IX Item "%%"
422 two consecutive \f(CW\*(C`%\*(C'\fR characters are collapsed into a single \f(CW\*(C`%\*(C'\fR character
423 .RE
424 .RS 12
425 .Sp
426 The prompt specified by the \fB\-p\fR option will override the system
427 password prompt on systems that support \s-1PAM\s0 unless the
428 \&\fIpassprompt_override\fR flag is disabled in \fIsudoers\fR.
429 .RE
430 @SEMAN@.IP "\-r \fIrole\fR" 12
431 @SEMAN@.IX Item "-r role"
432 @SEMAN@The \fB\-r\fR (\fIrole\fR) option causes the new (SELinux) security context to 
433 @SEMAN@have the role specified by \fIrole\fR.
434 .IP "\-S" 12
435 .IX Item "-S"
436 The \fB\-S\fR (\fIstdin\fR) option causes \fBsudo\fR to read the password from
437 the standard input instead of the terminal device.  The password must
438 be followed by a newline character.
439 .IP "\-s [command]" 12
440 .IX Item "-s [command]"
441 The \fB\-s\fR (\fIshell\fR) option runs the shell specified by the \fI\s-1SHELL\s0\fR
442 environment variable if it is set or the shell as specified in
443 \&\fIpasswd\fR\|(@mansectform@).  If a command is specified, it is passed to the shell
444 for execution.  Otherwise, an interactive shell is executed.
445 @SEMAN@.IP "\-t \fItype\fR" 12
446 @SEMAN@.IX Item "-t type"
447 @SEMAN@The \fB\-t\fR (\fItype\fR) option causes the new (SELinux) security context to 
448 @SEMAN@have the type specified by \fItype\fR.  If no type is specified, the default
449 @SEMAN@type is derived from the specified role.
450 .IP "\-U \fIuser\fR" 12
451 .IX Item "-U user"
452 The \fB\-U\fR (\fIother user\fR) option is used in conjunction with the \fB\-l\fR
453 option to specify the user whose privileges should be listed.  Only
454 root or a user with \fBsudo\fR \f(CW\*(C`ALL\*(C'\fR on the current host may use this
455 option.
456 .IP "\-u \fIuser\fR" 12
457 .IX Item "-u user"
458 The \fB\-u\fR (\fIuser\fR) option causes \fBsudo\fR to run the specified
459 command as a user other than \fIroot\fR.  To specify a \fIuid\fR instead
460 of a \fIuser name\fR, use \fI#uid\fR.  When running commands as a \fIuid\fR,
461 many shells require that the '#' be escaped with a backslash ('\e').
462 Note that if the \fItargetpw\fR Defaults option is set (see \fIsudoers\fR\|(@mansectform@))
463 it is not possible to run commands with a uid not listed in the
464 password database.
465 .IP "\-V" 12
466 .IX Item "-V"
467 The \fB\-V\fR (\fIversion\fR) option causes \fBsudo\fR to print the version
468 number and exit.  If the invoking user is already root the \fB\-V\fR
469 option will print out a list of the defaults \fBsudo\fR was compiled
470 with as well as the machine's local network addresses.
471 .IP "\-v" 12
472 .IX Item "-v"
473 If given the \fB\-v\fR (\fIvalidate\fR) option, \fBsudo\fR will update the
474 user's timestamp, prompting for the user's password if necessary.
475 This extends the \fBsudo\fR timeout for another \f(CW\*(C`@timeout@\*(C'\fR minutes
476 (or whatever the timeout is set to in \fIsudoers\fR) but does not run
477 a command.
478 .IP "\-\-" 12
479 The \fB\-\-\fR option indicates that \fBsudo\fR should stop processing command
480 line arguments.  It is most useful in conjunction with the \fB\-s\fR option.
481 .PP
482 Environment variables to be set for the command may also be passed
483 on the command line in the form of \fB\s-1VAR\s0\fR=\fIvalue\fR, e.g.
484 \&\fB\s-1LD_LIBRARY_PATH\s0\fR=\fI/usr/local/pkg/lib\fR.  Variables passed on the
485 command line are subject to the same restrictions as normal environment
486 variables with one important exception.  If the \fIsetenv\fR option
487 is set in \fIsudoers\fR, the command to be run has the \f(CW\*(C`SETENV\*(C'\fR tag
488 set or the command matched is \f(CW\*(C`ALL\*(C'\fR, the user may set variables
489 that would overwise be forbidden.  See \fIsudoers\fR\|(@mansectform@) for more information.
490 .SH "RETURN VALUES"
491 .IX Header "RETURN VALUES"
492 Upon successful execution of a program, the exit status from \fBsudo\fR
493 will simply be the exit status of the program that was executed.
494 .PP
495 Otherwise, \fBsudo\fR quits with an exit value of 1 if there is a
496 configuration/permission problem or if \fBsudo\fR cannot execute the
497 given command.  In the latter case the error string is printed to
498 stderr.  If \fBsudo\fR cannot \fIstat\fR\|(2) one or more entries in the user's
499 \&\f(CW\*(C`PATH\*(C'\fR an error is printed on stderr.  (If the directory does not
500 exist or if it is not really a directory, the entry is ignored and
501 no error is printed.)  This should not happen under normal
502 circumstances.  The most common reason for \fIstat\fR\|(2) to return
503 \&\*(L"permission denied\*(R" is if you are running an automounter and one
504 of the directories in your \f(CW\*(C`PATH\*(C'\fR is on a machine that is currently
505 unreachable.
506 .SH "SECURITY NOTES"
507 .IX Header "SECURITY NOTES"
508 \&\fBsudo\fR tries to be safe when executing external commands.
509 .PP
510 There are two distinct ways to deal with environment variables.
511 By default, the \fIenv_reset\fR \fIsudoers\fR option is enabled.
512 This causes commands to be executed with a minimal environment
513 containing \f(CW\*(C`TERM\*(C'\fR, \f(CW\*(C`PATH\*(C'\fR, \f(CW\*(C`HOME\*(C'\fR, \f(CW\*(C`SHELL\*(C'\fR, \f(CW\*(C`LOGNAME\*(C'\fR, \f(CW\*(C`USER\*(C'\fR
514 and \f(CW\*(C`USERNAME\*(C'\fR in addition to variables from the invoking process
515 permitted by the \fIenv_check\fR and \fIenv_keep\fR \fIsudoers\fR options.
516 There is effectively a whitelist for environment variables.
517 .PP
518 If, however, the \fIenv_reset\fR option is disabled in \fIsudoers\fR, any
519 variables not explicitly denied by the \fIenv_check\fR and \fIenv_delete\fR
520 options are inherited from the invoking process.  In this case,
521 \&\fIenv_check\fR and \fIenv_delete\fR behave like a blacklist.  Since it
522 is not possible to blacklist all potentially dangerous environment
523 variables, use of the default \fIenv_reset\fR behavior is encouraged.
524 .PP
525 In all cases, environment variables with a value beginning with
526 \&\f(CW\*(C`()\*(C'\fR are removed as they could be interpreted as \fBbash\fR functions.
527 The list of environment variables that \fBsudo\fR allows or denies is
528 contained in the output of \f(CW\*(C`sudo \-V\*(C'\fR when run as root.
529 .PP
530 Note that the dynamic linker on most operating systems will remove
531 variables that can control dynamic linking from the environment of
532 setuid executables, including \fBsudo\fR.  Depending on the operating
533 system this may include \f(CW\*(C`_RLD*\*(C'\fR, \f(CW\*(C`DYLD_*\*(C'\fR, \f(CW\*(C`LD_*\*(C'\fR, \f(CW\*(C`LDR_*\*(C'\fR,
534 \&\f(CW\*(C`LIBPATH\*(C'\fR, \f(CW\*(C`SHLIB_PATH\*(C'\fR, and others.  These type of variables are
535 removed from the environment before \fBsudo\fR even begins execution
536 and, as such, it is not possible for \fBsudo\fR to preserve them.
537 .PP
538 To prevent command spoofing, \fBsudo\fR checks \*(L".\*(R" and "" (both denoting
539 current directory) last when searching for a command in the user's
540 \&\s-1PATH\s0 (if one or both are in the \s-1PATH\s0).  Note, however, that the
541 actual \f(CW\*(C`PATH\*(C'\fR environment variable is \fInot\fR modified and is passed
542 unchanged to the program that \fBsudo\fR executes.
543 .PP
544 \&\fBsudo\fR will check the ownership of its timestamp directory
545 (\fI@timedir@\fR by default) and ignore the directory's contents if
546 it is not owned by root or if it is writable by a user other than
547 root.  On systems that allow non-root users to give away files via
548 \&\fIchown\fR\|(2), if the timestamp directory is located in a directory
549 writable by anyone (e.g., \fI/tmp\fR), it is possible for a user to
550 create the timestamp directory before \fBsudo\fR is run.  However,
551 because \fBsudo\fR checks the ownership and mode of the directory and
552 its contents, the only damage that can be done is to \*(L"hide\*(R" files
553 by putting them in the timestamp dir.  This is unlikely to happen
554 since once the timestamp dir is owned by root and inaccessible by
555 any other user, the user placing files there would be unable to get
556 them back out.  To get around this issue you can use a directory
557 that is not world-writable for the timestamps (\fI/var/adm/sudo\fR for
558 instance) or create \fI@timedir@\fR with the appropriate owner (root)
559 and permissions (0700) in the system startup files.
560 .PP
561 \&\fBsudo\fR will not honor timestamps set far in the future.
562 Timestamps with a date greater than current_time + 2 * \f(CW\*(C`TIMEOUT\*(C'\fR
563 will be ignored and sudo will log and complain.  This is done to
564 keep a user from creating his/her own timestamp with a bogus
565 date on systems that allow users to give away files.
566 .PP
567 Please note that \fBsudo\fR will normally only log the command it
568 explicitly runs.  If a user runs a command such as \f(CW\*(C`sudo su\*(C'\fR or
569 \&\f(CW\*(C`sudo sh\*(C'\fR, subsequent commands run from that shell will \fInot\fR be
570 logged, nor will \fBsudo\fR's access control affect them.  The same
571 is true for commands that offer shell escapes (including most
572 editors).  Because of this, care must be taken when giving users
573 access to commands via \fBsudo\fR to verify that the command does not
574 inadvertently give the user an effective root shell.  For more
575 information, please see the \f(CW\*(C`PREVENTING SHELL ESCAPES\*(C'\fR section in
576 \&\fIsudoers\fR\|(@mansectform@).
577 .SH "ENVIRONMENT"
578 .IX Header "ENVIRONMENT"
579 \&\fBsudo\fR utilizes the following environment variables:
580 .ie n .IP "\*(C`EDITOR\*(C'" 16
581 .el .IP "\f(CW\*(C`EDITOR\*(C'\fR" 16
582 .IX Item "EDITOR"
583 Default editor to use in \fB\-e\fR (sudoedit) mode if neither \f(CW\*(C`SUDO_EDITOR\*(C'\fR
584 nor \f(CW\*(C`VISUAL\*(C'\fR is set
585 .ie n .IP "\*(C`HOME\*(C'" 16
586 .el .IP "\f(CW\*(C`HOME\*(C'\fR" 16
587 .IX Item "HOME"
588 In \fB\-s\fR or \fB\-H\fR mode (or if sudo was configured with the
589 \&\-\-enable\-shell\-sets\-home option), set to homedir of the target user
590 .ie n .IP "\*(C`PATH\*(C'" 16
591 .el .IP "\f(CW\*(C`PATH\*(C'\fR" 16
592 .IX Item "PATH"
593 Set to a sane value if the \fIsecure_path\fR sudoers option is set.
594 .ie n .IP "\*(C`SHELL\*(C'" 16
595 .el .IP "\f(CW\*(C`SHELL\*(C'\fR" 16
596 .IX Item "SHELL"
597 Used to determine shell to run with \f(CW\*(C`\-s\*(C'\fR option
598 .ie n .IP "\*(C`SUDO_ASKPASS\*(C'" 16
599 .el .IP "\f(CW\*(C`SUDO_ASKPASS\*(C'\fR" 16
600 .IX Item "SUDO_ASKPASS"
601 Specifies the path to a helper program used to read the password
602 if no terminal is available or if the \f(CW\*(C`\-A\*(C'\fR option is specified.
603 .ie n .IP "\*(C`SUDO_COMMAND\*(C'" 16
604 .el .IP "\f(CW\*(C`SUDO_COMMAND\*(C'\fR" 16
605 .IX Item "SUDO_COMMAND"
606 Set to the command run by sudo
607 .ie n .IP "\*(C`SUDO_EDITOR\*(C'" 16
608 .el .IP "\f(CW\*(C`SUDO_EDITOR\*(C'\fR" 16
609 .IX Item "SUDO_EDITOR"
610 Default editor to use in \fB\-e\fR (sudoedit) mode
611 .ie n .IP "\*(C`SUDO_GID\*(C'" 16
612 .el .IP "\f(CW\*(C`SUDO_GID\*(C'\fR" 16
613 .IX Item "SUDO_GID"
614 Set to the group \s-1ID\s0 of the user who invoked sudo
615 .ie n .IP "\*(C`SUDO_PROMPT\*(C'" 16
616 .el .IP "\f(CW\*(C`SUDO_PROMPT\*(C'\fR" 16
617 .IX Item "SUDO_PROMPT"
618 Used as the default password prompt
619 .ie n .IP "\*(C`SUDO_PS1\*(C'" 16
620 .el .IP "\f(CW\*(C`SUDO_PS1\*(C'\fR" 16
621 .IX Item "SUDO_PS1"
622 If set, \f(CW\*(C`PS1\*(C'\fR will be set to its value for the program being run
623 .ie n .IP "\*(C`SUDO_UID\*(C'" 16
624 .el .IP "\f(CW\*(C`SUDO_UID\*(C'\fR" 16
625 .IX Item "SUDO_UID"
626 Set to the user \s-1ID\s0 of the user who invoked sudo
627 .ie n .IP "\*(C`SUDO_USER\*(C'" 16
628 .el .IP "\f(CW\*(C`SUDO_USER\*(C'\fR" 16
629 .IX Item "SUDO_USER"
630 Set to the login of the user who invoked sudo
631 .ie n .IP "\*(C`USER\*(C'" 16
632 .el .IP "\f(CW\*(C`USER\*(C'\fR" 16
633 .IX Item "USER"
634 Set to the target user (root unless the \fB\-u\fR option is specified)
635 .ie n .IP "\*(C`VISUAL\*(C'" 16
636 .el .IP "\f(CW\*(C`VISUAL\*(C'\fR" 16
637 .IX Item "VISUAL"
638 Default editor to use in \fB\-e\fR (sudoedit) mode if \f(CW\*(C`SUDO_EDITOR\*(C'\fR
639 is not set
640 .SH "FILES"
641 .IX Header "FILES"
642 .ie n .IP "\fI@sysconfdir@/sudoers\fR" 24
643 .el .IP "\fI@sysconfdir@/sudoers\fR" 24
644 .IX Item "@sysconfdir@/sudoers"
645 List of who can run what
646 .ie n .IP "\fI@timedir@\fR" 24
647 .el .IP "\fI@timedir@\fR" 24
648 .IX Item "@timedir@"
649 Directory containing timestamps
650 .IP "\fI/etc/environment\fR" 24
651 .IX Item "/etc/environment"
652 Initial environment for \fB\-i\fR mode on Linux and \s-1AIX\s0
653 .SH "EXAMPLES"
654 .IX Header "EXAMPLES"
655 Note: the following examples assume suitable \fIsudoers\fR\|(@mansectform@) entries.
656 .PP
657 To get a file listing of an unreadable directory:
658 .PP
659 .Vb 1
660 \& $ sudo ls /usr/local/protected
661 .Ve
662 .PP
663 To list the home directory of user yaz on a machine where the
664 file system holding ~yaz is not exported as root:
665 .PP
666 .Vb 1
667 \& $ sudo \-u yaz ls ~yaz
668 .Ve
669 .PP
670 To edit the \fIindex.html\fR file as user www:
671 .PP
672 .Vb 1
673 \& $ sudo \-u www vi ~www/htdocs/index.html
674 .Ve
675 .PP
676 To view system logs only accessible to root and users in the adm group:
677 .PP
678 .Vb 1
679 \& $ sudo \-g adm view /var/log/syslog
680 .Ve
681 .PP
682 To run an editor as jim with a different primary group:
683 .PP
684 .Vb 1
685 \& $ sudo \-u jim \-g audio vi ~jim/sound.txt
686 .Ve
687 .PP
688 To shutdown a machine:
689 .PP
690 .Vb 1
691 \& $ sudo shutdown \-r +15 "quick reboot"
692 .Ve
693 .PP
694 To make a usage listing of the directories in the /home
695 partition.  Note that this runs the commands in a sub-shell
696 to make the \f(CW\*(C`cd\*(C'\fR and file redirection work.
697 .PP
698 .Vb 1
699 \& $ sudo sh \-c "cd /home ; du \-s * | sort \-rn > USAGE"
700 .Ve
701 .SH "SEE ALSO"
702 .IX Header "SEE ALSO"
703 \&\fIgrep\fR\|(1), \fIsu\fR\|(1), \fIstat\fR\|(2),
704 @LCMAN@\&\fIlogin_cap\fR\|(3),
705 \&\fIpasswd\fR\|(@mansectform@), \fIsudoers\fR\|(5), \fIvisudo\fR\|(@mansectsu@)
706 .SH "AUTHORS"
707 .IX Header "AUTHORS"
708 Many people have worked on \fBsudo\fR over the years; this
709 version consists of code written primarily by:
710 .PP
711 .Vb 1
712 \&        Todd C. Miller
713 .Ve
714 .PP
715 See the \s-1HISTORY\s0 file in the \fBsudo\fR distribution or visit
716 http://www.sudo.ws/sudo/history.html for a short history
717 of \fBsudo\fR.
718 .SH "CAVEATS"
719 .IX Header "CAVEATS"
720 There is no easy way to prevent a user from gaining a root shell
721 if that user is allowed to run arbitrary commands via \fBsudo\fR.
722 Also, many programs (such as editors) allow the user to run commands
723 via shell escapes, thus avoiding \fBsudo\fR's checks.  However, on
724 most systems it is possible to prevent shell escapes with \fBsudo\fR's
725 \&\fInoexec\fR functionality.  See the \fIsudoers\fR\|(@mansectform@) manual
726 for details.
727 .PP
728 It is not meaningful to run the \f(CW\*(C`cd\*(C'\fR command directly via sudo, e.g.,
729 .PP
730 .Vb 1
731 \& $ sudo cd /usr/local/protected
732 .Ve
733 .PP
734 since when the command exits the parent process (your shell) will
735 still be the same.  Please see the \s-1EXAMPLES\s0 section for more information.
736 .PP
737 If users have sudo \f(CW\*(C`ALL\*(C'\fR there is nothing to prevent them from
738 creating their own program that gives them a root shell regardless
739 of any '!' elements in the user specification.
740 .PP
741 Running shell scripts via \fBsudo\fR can expose the same kernel bugs that
742 make setuid shell scripts unsafe on some operating systems (if your \s-1OS\s0
743 has a /dev/fd/ directory, setuid shell scripts are generally safe).
744 .SH "BUGS"
745 .IX Header "BUGS"
746 If you feel you have found a bug in \fBsudo\fR, please submit a bug report
747 at http://www.sudo.ws/sudo/bugs/
748 .SH "SUPPORT"
749 .IX Header "SUPPORT"
750 Limited free support is available via the sudo-users mailing list,
751 see http://www.sudo.ws/mailman/listinfo/sudo\-users to subscribe or
752 search the archives.
753 .SH "DISCLAIMER"
754 .IX Header "DISCLAIMER"
755 \&\fBsudo\fR is provided ``\s-1AS\s0 \s-1IS\s0'' and any express or implied warranties,
756 including, but not limited to, the implied warranties of merchantability
757 and fitness for a particular purpose are disclaimed.  See the \s-1LICENSE\s0
758 file distributed with \fBsudo\fR or http://www.sudo.ws/sudo/license.html
759 for complete details.