man pages get built in the build- directories
[debian/sudo] / sudo.man.in
1 .\" Copyright (c) 1994-1996, 1998-2005, 2007-2008
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.53 2008/11/15 18:34:26 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@ "November 15, 2008" "1.7.0" "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\-n\fR] \fB\-h\fR | \fB\-K\fR | \fB\-k\fR | \fB\-L\fR | \fB\-V\fR | \fB\-v\fR
166 .PP
167 \&\fBsudo\fR \fB\-l[l]\fR [\fB\-AnS\fR] [\fB\-g\fR\ \fIgroupname\fR|\fI#gid\fR] [\fB\-U\fR\ \fIusername\fR]
168 [\fB\-u\fR\ \fIusername\fR|\fI#uid\fR] [\fIcommand\fR]
169 .PP
170 \&\fBsudo\fR [\fB\-AbEHnPS\fR]
171 @BAMAN@[\fB\-a\fR\ \fIauth_type\fR]
172 [\fB\-C\fR\ \fIfd\fR]
173 @LCMAN@[\fB\-c\fR\ \fIclass\fR|\fI\-\fR]
174 [\fB\-g\fR\ \fIgroupname\fR|\fI#gid\fR] [\fB\-p\fR\ \fIprompt\fR]
175 @SEMAN@[\fB\-r\fR\ \fIrole\fR] [\fB\-t\fR\ \fItype\fR]
176 [\fB\-u\fR\ \fIusername\fR|\fI#uid\fR]
177 [\fB\s-1VAR\s0\fR=\fIvalue\fR] [\fB\-i\fR\ |\ \fB\-s\fR] [\fIcommand\fR]
178 .PP
179 \&\fBsudoedit\fR [\fB\-AnS\fR]
180 @BAMAN@[\fB\-a\fR\ \fIauth_type\fR]
181 [\fB\-C\fR\ \fIfd\fR]
182 @LCMAN@[\fB\-c\fR\ \fIclass\fR|\fI\-\fR]
183 [\fB\-g\fR\ \fIgroupname\fR|\fI#gid\fR] [\fB\-p\fR\ \fIprompt\fR]
184 [\fB\-u\fR\ \fIusername\fR|\fI#uid\fR] file ...
185 .SH "DESCRIPTION"
186 .IX Header "DESCRIPTION"
187 \&\fBsudo\fR allows a permitted user to execute a \fIcommand\fR as the
188 superuser or another user, as specified in the \fIsudoers\fR file.
189 The real and effective uid and gid are set to match those of the
190 target user as specified in the passwd file and the group vector
191 is initialized based on the group file (unless the \fB\-P\fR option was
192 specified).  If the invoking user is root or if the target user is
193 the same as the invoking user, no password is required.  Otherwise,
194 \&\fBsudo\fR requires that users authenticate themselves with a password
195 by default (\s-1NOTE:\s0 in the default configuration this is the user's
196 password, not the root password).  Once a user has been authenticated,
197 a timestamp is updated and the user may then use sudo without a
198 password for a short period of time (\f(CW\*(C`@timeout@\*(C'\fR minutes unless
199 overridden in \fIsudoers\fR).
200 .PP
201 When invoked as \fBsudoedit\fR, the \fB\-e\fR option (described below),
202 is implied.
203 .PP
204 \&\fBsudo\fR determines who is an authorized user by consulting the file
205 \&\fI@sysconfdir@/sudoers\fR.  By running \fBsudo\fR with the \fB\-v\fR option,
206 a user can update the time stamp without running a \fIcommand\fR. The
207 password prompt itself will also time out if the user's password
208 is not entered within \f(CW\*(C`@password_timeout@\*(C'\fR minutes (unless overridden
209 via \fIsudoers\fR).
210 .PP
211 If a user who is not listed in the \fIsudoers\fR file tries to run a
212 command via \fBsudo\fR, mail is sent to the proper authorities, as
213 defined at configure time or in the \fIsudoers\fR file (defaults to
214 \&\f(CW\*(C`@mailto@\*(C'\fR).  Note that the mail will not be sent if an unauthorized
215 user tries to run sudo with the \fB\-l\fR or \fB\-v\fR option.  This allows
216 users to determine for themselves whether or not they are allowed
217 to use \fBsudo\fR.
218 .PP
219 If \fBsudo\fR is run by root and the \f(CW\*(C`SUDO_USER\*(C'\fR environment variable
220 is set, \fBsudo\fR will use this value to determine who the actual
221 user is.  This can be used by a user to log commands through sudo
222 even when a root shell has been invoked.  It also allows the \fB\-e\fR
223 option to remain useful even when being run via a sudo-run script or
224 program.  Note however, that the sudoers lookup is still done for
225 root, not the user specified by \f(CW\*(C`SUDO_USER\*(C'\fR.
226 .PP
227 \&\fBsudo\fR can log both successful and unsuccessful attempts (as well
228 as errors) to \fIsyslog\fR\|(3), a log file, or both.  By default \fBsudo\fR
229 will log via \fIsyslog\fR\|(3) but this is changeable at configure time
230 or via the \fIsudoers\fR file.
231 .SH "OPTIONS"
232 .IX Header "OPTIONS"
233 \&\fBsudo\fR accepts the following command line options:
234 .IP "\-A" 12
235 .IX Item "-A"
236 Normally, if \fBsudo\fR requires a password, it will read it from the
237 current terminal.  If the \fB\-A\fR (\fIaskpass\fR) option is specified,
238 a helper program is executed to read the user's password and output
239 the password to the standard output.  If the \f(CW\*(C`SUDO_ASKPASS\*(C'\fR
240 environment variable is set, it specifies the path to the helper
241 program.  Otherwise, the value specified by the \fIaskpass\fR option
242 in \fIsudoers\fR\|(@mansectform@) is used.
243 @BAMAN@.IP "\-a \fItype\fR" 12
244 @BAMAN@.IX Item "-a type"
245 @BAMAN@The \fB\-a\fR (\fIauthentication type\fR) option causes \fBsudo\fR to use the
246 @BAMAN@specified authentication type when validating the user, as allowed
247 @BAMAN@by \fI/etc/login.conf\fR.  The system administrator may specify a list
248 @BAMAN@of sudo-specific authentication methods by adding an \*(L"auth-sudo\*(R"
249 @BAMAN@entry in \fI/etc/login.conf\fR.  This option is only available on systems
250 @BAMAN@that support \s-1BSD\s0 authentication.
251 .IP "\-b" 12
252 .IX Item "-b"
253 The \fB\-b\fR (\fIbackground\fR) option tells \fBsudo\fR to run the given
254 command in the background.  Note that if you use the \fB\-b\fR
255 option you cannot use shell job control to manipulate the process.
256 .IP "\-C \fIfd\fR" 12
257 .IX Item "-C fd"
258 Normally, \fBsudo\fR will close all open file descriptors other than
259 standard input, standard output and standard error.  The \fB\-C\fR
260 (\fIclose from\fR) option allows the user to specify a starting point
261 above the standard error (file descriptor three).  Values less than
262 three are not permitted.  This option is only available if the
263 administrator has enabled the \fIclosefrom_override\fR option in
264 \&\fIsudoers\fR\|(@mansectform@).
265 @LCMAN@.IP "\-c \fIclass\fR" 12
266 @LCMAN@.IX Item "-c class"
267 @LCMAN@The \fB\-c\fR (\fIclass\fR) option causes \fBsudo\fR to run the specified command
268 @LCMAN@with resources limited by the specified login class.  The \fIclass\fR
269 @LCMAN@argument can be either a class name as defined in \fI/etc/login.conf\fR,
270 @LCMAN@or a single '\-' character.  Specifying a \fIclass\fR of \f(CW\*(C`\-\*(C'\fR indicates
271 @LCMAN@that the command should be run restricted by the default login
272 @LCMAN@capabilities for the user the command is run as.  If the \fIclass\fR
273 @LCMAN@argument specifies an existing user class, the command must be run
274 @LCMAN@as root, or the \fBsudo\fR command must be run from a shell that is already
275 @LCMAN@root.  This option is only available on systems with \s-1BSD\s0 login classes.
276 .IP "\-E" 12
277 .IX Item "-E"
278 The \fB\-E\fR (\fIpreserve\fR \fIenvironment\fR) option will override the
279 \&\fIenv_reset\fR option in \fIsudoers\fR\|(@mansectform@)).  It is only
280 available when either the matching command has the \f(CW\*(C`SETENV\*(C'\fR tag
281 or the \fIsetenv\fR option is set in \fIsudoers\fR\|(@mansectform@).
282 .IP "\-e" 12
283 .IX Item "-e"
284 The \fB\-e\fR (\fIedit\fR) option indicates that, instead of running
285 a command, the user wishes to edit one or more files.  In lieu
286 of a command, the string \*(L"sudoedit\*(R" is used when consulting
287 the \fIsudoers\fR file.  If the user is authorized by \fIsudoers\fR
288 the following steps are taken:
289 .RS 12
290 .IP "1." 4
291 Temporary copies are made of the files to be edited with the owner
292 set to the invoking user.
293 .IP "2." 4
294 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
295 environment variables is run to edit the temporary files.  If none
296 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
297 listed in the \fIeditor\fR \fIsudoers\fR variable is used.
298 .IP "3." 4
299 If they have been modified, the temporary files are copied back to
300 their original location and the temporary versions are removed.
301 .RE
302 .RS 12
303 .Sp
304 If the specified file does not exist, it will be created.  Note
305 that unlike most commands run by \fBsudo\fR, the editor is run with
306 the invoking user's environment unmodified.  If, for some reason,
307 \&\fBsudo\fR is unable to update a file with its edited version, the
308 user will receive a warning and the edited copy will remain in a
309 temporary file.
310 .RE
311 .IP "\-g \fIgroup\fR" 12
312 .IX Item "-g group"
313 Normally, \fBsudo\fR sets the primary group to the one specified by
314 the passwd database for the user the command is being run as (by
315 default, root).  The \fB\-g\fR (\fIgroup\fR) option causes \fBsudo\fR to run
316 the specified command with the primary group set to \fIgroup\fR.  To
317 specify a \fIgid\fR instead of a \fIgroup name\fR, use \fI#gid\fR.  When
318 running commands as a \fIgid\fR, many shells require that the '#' be
319 escaped with a backslash ('\e').  If no \fB\-u\fR option is specified,
320 the command will be run as the invoking user (not root).  In either
321 case, the primary group will be set to \fIgroup\fR.
322 .IP "\-H" 12
323 .IX Item "-H"
324 The \fB\-H\fR (\fI\s-1HOME\s0\fR) option sets the \f(CW\*(C`HOME\*(C'\fR environment variable
325 to the homedir of the target user (root by default) as specified
326 in \fIpasswd\fR\|(@mansectform@).  By default, \fBsudo\fR does not modify \f(CW\*(C`HOME\*(C'\fR
327 (see \fIset_home\fR and \fIalways_set_home\fR in \fIsudoers\fR\|(@mansectform@)).
328 .IP "\-h" 12
329 .IX Item "-h"
330 The \fB\-h\fR (\fIhelp\fR) option causes \fBsudo\fR to print a usage message and exit.
331 .IP "\-i [command]" 12
332 .IX Item "-i [command]"
333 The \fB\-i\fR (\fIsimulate initial login\fR) option runs the shell specified
334 in the \fIpasswd\fR\|(@mansectform@) entry of the target user as a login shell.  This
335 means that login-specific resource files such as \f(CW\*(C`.profile\*(C'\fR or
336 \&\f(CW\*(C`.login\*(C'\fR will be read by the shell.  If a command is specified,
337 it is passed to the shell for execution.  Otherwise, an interactive
338 shell is executed.  \fBsudo\fR attempts to change to that user's home
339 directory before running the shell.  It also initializes the
340 environment, leaving \fI\s-1DISPLAY\s0\fR and \fI\s-1TERM\s0\fR unchanged, setting
341 \&\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
342 the contents of \fI/etc/environment\fR on Linux and \s-1AIX\s0 systems.
343 All other environment variables are removed.
344 .IP "\-K" 12
345 .IX Item "-K"
346 The \fB\-K\fR (sure \fIkill\fR) option is like \fB\-k\fR except that it removes
347 the user's timestamp entirely.  Like \fB\-k\fR, this option does not
348 require a password.
349 .IP "\-k" 12
350 .IX Item "-k"
351 The \fB\-k\fR (\fIkill\fR) option to \fBsudo\fR invalidates the user's timestamp
352 by setting the time on it to the Epoch.  The next time \fBsudo\fR is
353 run a password will be required.  This option does not require a password
354 and was added to allow a user to revoke \fBsudo\fR permissions from a .logout
355 file.
356 .IP "\-L" 12
357 .IX Item "-L"
358 The \fB\-L\fR (\fIlist\fR defaults) option will list out the parameters
359 that may be set in a \fIDefaults\fR line along with a short description
360 for each.  This option is useful in conjunction with \fIgrep\fR\|(1).
361 .IP "\-l[l] [\fIcommand\fR]" 12
362 .IX Item "-l[l] [command]"
363 If no \fIcommand\fR is specified, the \fB\-l\fR (\fIlist\fR) option will list
364 the allowed (and forbidden) commands for the invoking user (or the
365 user specified by the \fB\-U\fR option) on the current host.  If a
366 \&\fIcommand\fR is specified and is permitted by \fIsudoers\fR, the
367 fully-qualified path to the command is displayed along with any
368 command line arguments.  If \fIcommand\fR is specified but not allowed,
369 \&\fBsudo\fR will exit with a status value of 1.  If the \fB\-l\fR option is
370 specified with an \fBl\fR argument (i.e. \fB\-ll\fR), or if \fB\-l\fR
371 is specified multiple times, a longer list format is used.
372 .IP "\-n" 12
373 .IX Item "-n"
374 The \fB\-n\fR (\fInon-interactive\fR) option prevents \fBsudo\fR from prompting
375 the user for a password.  If a password is required for the command
376 to run, \fBsudo\fR will display an error messages and exit.
377 .IP "\-P" 12
378 .IX Item "-P"
379 The \fB\-P\fR (\fIpreserve\fR \fIgroup vector\fR) option causes \fBsudo\fR to
380 preserve the invoking user's group vector unaltered.  By default,
381 \&\fBsudo\fR will initialize the group vector to the list of groups the
382 target user is in.  The real and effective group IDs, however, are
383 still set to match the target user.
384 .IP "\-p \fIprompt\fR" 12
385 .IX Item "-p prompt"
386 The \fB\-p\fR (\fIprompt\fR) option allows you to override the default
387 password prompt and use a custom one.  The following percent (`\f(CW\*(C`%\*(C'\fR')
388 escapes are supported:
389 .RS 12
390 .ie n .IP "%H" 4
391 .el .IP "\f(CW%H\fR" 4
392 .IX Item "%H"
393 expanded to the local hostname including the domain name
394 (on if the machine's hostname is fully qualified or the \fIfqdn\fR
395 \&\fIsudoers\fR option is set)
396 .ie n .IP "%h" 4
397 .el .IP "\f(CW%h\fR" 4
398 .IX Item "%h"
399 expanded to the local hostname without the domain name
400 .ie n .IP "%p" 4
401 .el .IP "\f(CW%p\fR" 4
402 .IX Item "%p"
403 expanded to the user whose password is being asked for (respects the
404 \&\fIrootpw\fR, \fItargetpw\fR and \fIrunaspw\fR flags in \fIsudoers\fR)
405 .ie n .IP "%U" 4
406 .el .IP "\f(CW%U\fR" 4
407 .IX Item "%U"
408 expanded to the login name of the user the command will
409 be run as (defaults to root)
410 .ie n .IP "%u" 4
411 .el .IP "\f(CW%u\fR" 4
412 .IX Item "%u"
413 expanded to the invoking user's login name
414 .ie n .IP "\*(C`%%\*(C'" 4
415 .el .IP "\f(CW\*(C`%%\*(C'\fR" 4
416 .IX Item "%%"
417 two consecutive \f(CW\*(C`%\*(C'\fR characters are collapsed into a single \f(CW\*(C`%\*(C'\fR character
418 .RE
419 .RS 12
420 .Sp
421 The prompt specified by the \fB\-p\fR option will override the system
422 password prompt on systems that support \s-1PAM\s0 unless the
423 \&\fIpassprompt_override\fR flag is disabled in \fIsudoers\fR.
424 .RE
425 @SEMAN@.IP "\-r \fIrole\fR" 12
426 @SEMAN@.IX Item "-r role"
427 @SEMAN@The \fB\-r\fR (\fIrole\fR) option causes the new (SELinux) security context to 
428 @SEMAN@have the role specified by \fIrole\fR.
429 .IP "\-S" 12
430 .IX Item "-S"
431 The \fB\-S\fR (\fIstdin\fR) option causes \fBsudo\fR to read the password from
432 the standard input instead of the terminal device.
433 .IP "\-s [command]" 12
434 .IX Item "-s [command]"
435 The \fB\-s\fR (\fIshell\fR) option runs the shell specified by the \fI\s-1SHELL\s0\fR
436 environment variable if it is set or the shell as specified in
437 \&\fIpasswd\fR\|(@mansectform@).  If a command is specified, it is passed to the shell
438 for execution.  Otherwise, an interactive shell is executed.
439 @SEMAN@.IP "\-t \fItype\fR" 12
440 @SEMAN@.IX Item "-t type"
441 @SEMAN@The \fB\-t\fR (\fItype\fR) option causes the new (SELinux) security context to 
442 @SEMAN@have the type specified by \fItype\fR.  If no type is specified, the default
443 @SEMAN@type is derived from the specified role.
444 .IP "\-U \fIuser\fR" 12
445 .IX Item "-U user"
446 The \fB\-U\fR (\fIother user\fR) option is used in conjunction with the \fB\-l\fR
447 option to specify the user whose privileges should be listed.  Only
448 root or a user with \fBsudo\fR \f(CW\*(C`ALL\*(C'\fR on the current host may use this
449 option.
450 .IP "\-u \fIuser\fR" 12
451 .IX Item "-u user"
452 The \fB\-u\fR (\fIuser\fR) option causes \fBsudo\fR to run the specified
453 command as a user other than \fIroot\fR.  To specify a \fIuid\fR instead
454 of a \fIuser name\fR, use \fI#uid\fR.  When running commands as a \fIuid\fR,
455 many shells require that the '#' be escaped with a backslash ('\e').
456 Note that if the \fItargetpw\fR Defaults option is set (see \fIsudoers\fR\|(@mansectform@))
457 it is not possible to run commands with a uid not listed in the
458 password database.
459 .IP "\-V" 12
460 .IX Item "-V"
461 The \fB\-V\fR (\fIversion\fR) option causes \fBsudo\fR to print the version
462 number and exit.  If the invoking user is already root the \fB\-V\fR
463 option will print out a list of the defaults \fBsudo\fR was compiled
464 with as well as the machine's local network addresses.
465 .IP "\-v" 12
466 .IX Item "-v"
467 If given the \fB\-v\fR (\fIvalidate\fR) option, \fBsudo\fR will update the
468 user's timestamp, prompting for the user's password if necessary.
469 This extends the \fBsudo\fR timeout for another \f(CW\*(C`@timeout@\*(C'\fR minutes
470 (or whatever the timeout is set to in \fIsudoers\fR) but does not run
471 a command.
472 .IP "\-\-" 12
473 The \fB\-\-\fR option indicates that \fBsudo\fR should stop processing command
474 line arguments.  It is most useful in conjunction with the \fB\-s\fR option.
475 .PP
476 Environment variables to be set for the command may also be passed
477 on the command line in the form of \fB\s-1VAR\s0\fR=\fIvalue\fR, e.g.
478 \&\fB\s-1LD_LIBRARY_PATH\s0\fR=\fI/usr/local/pkg/lib\fR.  Variables passed on the
479 command line are subject to the same restrictions as normal environment
480 variables with one important exception.  If the \fIsetenv\fR option
481 is set in \fIsudoers\fR, the command to be run has the \f(CW\*(C`SETENV\*(C'\fR tag
482 set or the command matched is \f(CW\*(C`ALL\*(C'\fR, the user may set variables
483 that would overwise be forbidden.  See \fIsudoers\fR\|(@mansectform@) for more information.
484 .SH "RETURN VALUES"
485 .IX Header "RETURN VALUES"
486 Upon successful execution of a program, the exit status from \fBsudo\fR
487 will simply be the exit status of the program that was executed.
488 .PP
489 Otherwise, \fBsudo\fR quits with an exit value of 1 if there is a
490 configuration/permission problem or if \fBsudo\fR cannot execute the
491 given command.  In the latter case the error string is printed to
492 stderr.  If \fBsudo\fR cannot \fIstat\fR\|(2) one or more entries in the user's
493 \&\f(CW\*(C`PATH\*(C'\fR an error is printed on stderr.  (If the directory does not
494 exist or if it is not really a directory, the entry is ignored and
495 no error is printed.)  This should not happen under normal
496 circumstances.  The most common reason for \fIstat\fR\|(2) to return
497 \&\*(L"permission denied\*(R" is if you are running an automounter and one
498 of the directories in your \f(CW\*(C`PATH\*(C'\fR is on a machine that is currently
499 unreachable.
500 .SH "SECURITY NOTES"
501 .IX Header "SECURITY NOTES"
502 \&\fBsudo\fR tries to be safe when executing external commands.
503 .PP
504 There are two distinct ways to deal with environment variables.
505 By default, the \fIenv_reset\fR \fIsudoers\fR option is enabled.
506 This causes commands to be executed with a minimal environment
507 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
508 and \f(CW\*(C`USERNAME\*(C'\fR in addition to variables from the invoking process
509 permitted by the \fIenv_check\fR and \fIenv_keep\fR \fIsudoers\fR options.
510 There is effectively a whitelist for environment variables.
511 .PP
512 If, however, the \fIenv_reset\fR option is disabled in \fIsudoers\fR, any
513 variables not explicitly denied by the \fIenv_check\fR and \fIenv_delete\fR
514 options are inherited from the invoking process.  In this case,
515 \&\fIenv_check\fR and \fIenv_delete\fR behave like a blacklist.  Since it
516 is not possible to blacklist all potentially dangerous environment
517 variables, use of the default \fIenv_reset\fR behavior is encouraged.
518 .PP
519 In all cases, environment variables with a value beginning with
520 \&\f(CW\*(C`()\*(C'\fR are removed as they could be interpreted as \fBbash\fR functions.
521 The list of environment variables that \fBsudo\fR allows or denies is
522 contained in the output of \f(CW\*(C`sudo \-V\*(C'\fR when run as root.
523 .PP
524 Note that the dynamic linker on most operating systems will remove
525 variables that can control dynamic linking from the environment of
526 setuid executables, including \fBsudo\fR.  Depending on the operating
527 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,
528 \&\f(CW\*(C`LIBPATH\*(C'\fR, \f(CW\*(C`SHLIB_PATH\*(C'\fR, and others.  These type of variables are
529 removed from the environment before \fBsudo\fR even begins execution
530 and, as such, it is not possible for \fBsudo\fR to preserve them.
531 .PP
532 To prevent command spoofing, \fBsudo\fR checks \*(L".\*(R" and "" (both denoting
533 current directory) last when searching for a command in the user's
534 \&\s-1PATH\s0 (if one or both are in the \s-1PATH\s0).  Note, however, that the
535 \&\f(CW\*(C`PATH\*(C'\fR environment variable is further modified in Debian because of
536 the use of the \fI\s-1SECURE_PATH\s0\fR build option.
537 .PP
538 \&\fBsudo\fR will check the ownership of its timestamp directory
539 (\fI@timedir@\fR by default) and ignore the directory's contents if
540 it is not owned by root or if it is writable by a user other than
541 root.  On systems that allow non-root users to give away files via
542 \&\fIchown\fR\|(2), if the timestamp directory is located in a directory
543 writable by anyone (e.g., \fI/tmp\fR), it is possible for a user to
544 create the timestamp directory before \fBsudo\fR is run.  However,
545 because \fBsudo\fR checks the ownership and mode of the directory and
546 its contents, the only damage that can be done is to \*(L"hide\*(R" files
547 by putting them in the timestamp dir.  This is unlikely to happen
548 since once the timestamp dir is owned by root and inaccessible by
549 any other user, the user placing files there would be unable to get
550 them back out.  To get around this issue you can use a directory
551 that is not world-writable for the timestamps (\fI/var/adm/sudo\fR for
552 instance) or create \fI@timedir@\fR with the appropriate owner (root)
553 and permissions (0700) in the system startup files.
554 .PP
555 \&\fBsudo\fR will not honor timestamps set far in the future.
556 Timestamps with a date greater than current_time + 2 * \f(CW\*(C`TIMEOUT\*(C'\fR
557 will be ignored and sudo will log and complain.  This is done to
558 keep a user from creating his/her own timestamp with a bogus
559 date on systems that allow users to give away files.
560 .PP
561 Please note that \fBsudo\fR will normally only log the command it
562 explicitly runs.  If a user runs a command such as \f(CW\*(C`sudo su\*(C'\fR or
563 \&\f(CW\*(C`sudo sh\*(C'\fR, subsequent commands run from that shell will \fInot\fR be
564 logged, nor will \fBsudo\fR's access control affect them.  The same
565 is true for commands that offer shell escapes (including most
566 editors).  Because of this, care must be taken when giving users
567 access to commands via \fBsudo\fR to verify that the command does not
568 inadvertently give the user an effective root shell.  For more
569 information, please see the \f(CW\*(C`PREVENTING SHELL ESCAPES\*(C'\fR section in
570 \&\fIsudoers\fR\|(@mansectform@).
571 .SH "ENVIRONMENT"
572 .IX Header "ENVIRONMENT"
573 \&\fBsudo\fR utilizes the following environment variables:
574 .ie n .IP "\*(C`EDITOR\*(C'" 16
575 .el .IP "\f(CW\*(C`EDITOR\*(C'\fR" 16
576 .IX Item "EDITOR"
577 Default editor to use in \fB\-e\fR (sudoedit) mode if neither \f(CW\*(C`SUDO_EDITOR\*(C'\fR
578 nor \f(CW\*(C`VISUAL\*(C'\fR is set
579 .ie n .IP "\*(C`HOME\*(C'" 16
580 .el .IP "\f(CW\*(C`HOME\*(C'\fR" 16
581 .IX Item "HOME"
582 In \fB\-s\fR or \fB\-H\fR mode (or if sudo was configured with the
583 \&\-\-enable\-shell\-sets\-home option), set to homedir of the target user
584 .ie n .IP "\*(C`PATH\*(C'" 16
585 .el .IP "\f(CW\*(C`PATH\*(C'\fR" 16
586 .IX Item "PATH"
587 Set to a sane value if the \fIsecure_path\fR sudoers option is set.
588 .ie n .IP "\*(C`SHELL\*(C'" 16
589 .el .IP "\f(CW\*(C`SHELL\*(C'\fR" 16
590 .IX Item "SHELL"
591 Used to determine shell to run with \f(CW\*(C`\-s\*(C'\fR option
592 .ie n .IP "\*(C`SUDO_ASKPASS\*(C'" 16
593 .el .IP "\f(CW\*(C`SUDO_ASKPASS\*(C'\fR" 16
594 .IX Item "SUDO_ASKPASS"
595 Specifies the path to a helper program used to read the password
596 if no terminal is available or if the \f(CW\*(C`\-A\*(C'\fR option is specified.
597 .ie n .IP "\*(C`SUDO_COMMAND\*(C'" 16
598 .el .IP "\f(CW\*(C`SUDO_COMMAND\*(C'\fR" 16
599 .IX Item "SUDO_COMMAND"
600 Set to the command run by sudo
601 .ie n .IP "\*(C`SUDO_EDITOR\*(C'" 16
602 .el .IP "\f(CW\*(C`SUDO_EDITOR\*(C'\fR" 16
603 .IX Item "SUDO_EDITOR"
604 Default editor to use in \fB\-e\fR (sudoedit) mode
605 .ie n .IP "\*(C`SUDO_GID\*(C'" 16
606 .el .IP "\f(CW\*(C`SUDO_GID\*(C'\fR" 16
607 .IX Item "SUDO_GID"
608 Set to the group \s-1ID\s0 of the user who invoked sudo
609 .ie n .IP "\*(C`SUDO_PROMPT\*(C'" 16
610 .el .IP "\f(CW\*(C`SUDO_PROMPT\*(C'\fR" 16
611 .IX Item "SUDO_PROMPT"
612 Used as the default password prompt
613 .ie n .IP "\*(C`SUDO_PS1\*(C'" 16
614 .el .IP "\f(CW\*(C`SUDO_PS1\*(C'\fR" 16
615 .IX Item "SUDO_PS1"
616 If set, \f(CW\*(C`PS1\*(C'\fR will be set to its value for the program being run
617 .ie n .IP "\*(C`SUDO_UID\*(C'" 16
618 .el .IP "\f(CW\*(C`SUDO_UID\*(C'\fR" 16
619 .IX Item "SUDO_UID"
620 Set to the user \s-1ID\s0 of the user who invoked sudo
621 .ie n .IP "\*(C`SUDO_USER\*(C'" 16
622 .el .IP "\f(CW\*(C`SUDO_USER\*(C'\fR" 16
623 .IX Item "SUDO_USER"
624 Set to the login of the user who invoked sudo
625 .ie n .IP "\*(C`USER\*(C'" 16
626 .el .IP "\f(CW\*(C`USER\*(C'\fR" 16
627 .IX Item "USER"
628 Set to the target user (root unless the \fB\-u\fR option is specified)
629 .ie n .IP "\*(C`VISUAL\*(C'" 16
630 .el .IP "\f(CW\*(C`VISUAL\*(C'\fR" 16
631 .IX Item "VISUAL"
632 Default editor to use in \fB\-e\fR (sudoedit) mode if \f(CW\*(C`SUDO_EDITOR\*(C'\fR
633 is not set
634 .SH "FILES"
635 .IX Header "FILES"
636 .ie n .IP "\fI@sysconfdir@/sudoers\fR" 24
637 .el .IP "\fI@sysconfdir@/sudoers\fR" 24
638 .IX Item "@sysconfdir@/sudoers"
639 List of who can run what
640 .ie n .IP "\fI@timedir@\fR" 24
641 .el .IP "\fI@timedir@\fR" 24
642 .IX Item "@timedir@"
643 Directory containing timestamps
644 .IP "\fI/etc/environment\fR" 24
645 .IX Item "/etc/environment"
646 Initial environment for \fB\-i\fR mode on Linux and \s-1AIX\s0
647 .SH "EXAMPLES"
648 .IX Header "EXAMPLES"
649 Note: the following examples assume suitable \fIsudoers\fR\|(@mansectform@) entries.
650 .PP
651 To get a file listing of an unreadable directory:
652 .PP
653 .Vb 1
654 \& $ sudo ls /usr/local/protected
655 .Ve
656 .PP
657 To list the home directory of user yazza on a machine where the
658 file system holding ~yazza is not exported as root:
659 .PP
660 .Vb 1
661 \& $ sudo \-u yazza ls ~yazza
662 .Ve
663 .PP
664 To edit the \fIindex.html\fR file as user www:
665 .PP
666 .Vb 1
667 \& $ sudo \-u www vi ~www/htdocs/index.html
668 .Ve
669 .PP
670 To shutdown a machine:
671 .PP
672 .Vb 1
673 \& $ sudo shutdown \-r +15 "quick reboot"
674 .Ve
675 .PP
676 To make a usage listing of the directories in the /home
677 partition.  Note that this runs the commands in a sub-shell
678 to make the \f(CW\*(C`cd\*(C'\fR and file redirection work.
679 .PP
680 .Vb 1
681 \& $ sudo sh \-c "cd /home ; du \-s * | sort \-rn > USAGE"
682 .Ve
683 .SH "SEE ALSO"
684 .IX Header "SEE ALSO"
685 \&\fIgrep\fR\|(1), \fIsu\fR\|(1), \fIstat\fR\|(2),
686 @LCMAN@\&\fIlogin_cap\fR\|(3),
687 \&\fIpasswd\fR\|(@mansectform@), \fIsudoers\fR\|(5), \fIvisudo\fR\|(@mansectsu@)
688 .PP
689 The file /usr/share/doc/sudo/OPTIONS describes the options used for building
690 the Debian version of sudo, some of which change default behaviors documented
691 elsewhere in this document.
692 .SH "AUTHORS"
693 .IX Header "AUTHORS"
694 Many people have worked on \fBsudo\fR over the years; this
695 version consists of code written primarily by:
696 .PP
697 .Vb 1
698 \&        Todd C. Miller
699 .Ve
700 .PP
701 See the \s-1HISTORY\s0 file in the \fBsudo\fR distribution or visit
702 http://www.sudo.ws/sudo/history.html for a short history
703 of \fBsudo\fR.
704 .SH "CAVEATS"
705 .IX Header "CAVEATS"
706 There is no easy way to prevent a user from gaining a root shell
707 if that user is allowed to run arbitrary commands via \fBsudo\fR.
708 Also, many programs (such as editors) allow the user to run commands
709 via shell escapes, thus avoiding \fBsudo\fR's checks.  However, on
710 most systems it is possible to prevent shell escapes with \fBsudo\fR's
711 \&\fInoexec\fR functionality.  See the \fIsudoers\fR\|(@mansectform@) manual
712 for details.
713 .PP
714 It is not meaningful to run the \f(CW\*(C`cd\*(C'\fR command directly via sudo, e.g.,
715 .PP
716 .Vb 1
717 \& $ sudo cd /usr/local/protected
718 .Ve
719 .PP
720 since when the command exits the parent process (your shell) will
721 still be the same.  Please see the \s-1EXAMPLES\s0 section for more information.
722 .PP
723 If users have sudo \f(CW\*(C`ALL\*(C'\fR there is nothing to prevent them from
724 creating their own program that gives them a root shell regardless
725 of any '!' elements in the user specification.
726 .PP
727 Running shell scripts via \fBsudo\fR can expose the same kernel bugs that
728 make setuid shell scripts unsafe on some operating systems (if your \s-1OS\s0
729 has a /dev/fd/ directory, setuid shell scripts are generally safe).
730 .SH "BUGS"
731 .IX Header "BUGS"
732 If you feel you have found a bug in \fBsudo\fR, please submit a bug report
733 at http://www.sudo.ws/sudo/bugs/
734 .SH "SUPPORT"
735 .IX Header "SUPPORT"
736 Limited free support is available via the sudo-users mailing list,
737 see http://www.sudo.ws/mailman/listinfo/sudo\-users to subscribe or
738 search the archives.
739 .SH "DISCLAIMER"
740 .IX Header "DISCLAIMER"
741 \&\fBsudo\fR is provided ``\s-1AS\s0 \s-1IS\s0'' and any express or implied warranties,
742 including, but not limited to, the implied warranties of merchantability
743 and fitness for a particular purpose are disclaimed.  See the \s-1LICENSE\s0
744 file distributed with \fBsudo\fR or http://www.sudo.ws/sudo/license.html
745 for complete details.