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