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