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