go back to using explicit install calls in rules due to renaming required
[debian/sudo] / sudo.pod
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 =pod
22
23 =head1 NAME
24
25 sudo, sudoedit - execute a command as another user
26
27 =head1 SYNOPSIS
28
29 B<sudo> B<-h> | B<-K> | B<-k> | B<-L> | B<-V>
30
31 B<sudo> B<-v> [B<-AknS>]
32 S<[B<-a> I<auth_type>]>
33 S<[B<-g> I<group name>|I<#gid>]> S<[B<-p> I<prompt>]>
34 S<[B<-u> I<username>|I<#uid>]>
35
36 B<sudo> B<-l[l]> [B<-AknS>]
37 S<[B<-a> I<auth_type>]>
38 S<[B<-g> I<group name>|I<#gid>]> S<[B<-p> I<prompt>]>
39 S<[B<-U> I<user name>]> S<[B<-u> I<user name>|I<#uid>]> [I<command>]
40
41 B<sudo> [B<-AbEHnPS>]
42 S<[B<-a> I<auth_type>]>
43 S<[B<-C> I<fd>]>
44 S<[B<-c> I<class>|I<->]>
45 S<[B<-g> I<group name>|I<#gid>]> S<[B<-p> I<prompt>]>
46 S<[B<-r> I<role>]> S<[B<-t> I<type>]>
47 S<[B<-u> I<user name>|I<#uid>]>
48 S<[B<VAR>=I<value>]> S<[B<-i> | B<-s>]> [I<command>]
49
50 B<sudoedit> [B<-AnS>]
51 S<[B<-a> I<auth_type>]>
52 S<[B<-C> I<fd>]>
53 S<[B<-c> I<class>|I<->]>
54 S<[B<-g> I<group name>|I<#gid>]> S<[B<-p> I<prompt>]>
55 S<[B<-u> I<user name>|I<#uid>]> file ...
56
57 =head1 DESCRIPTION
58
59 B<sudo> allows a permitted user to execute a I<command> as the
60 superuser or another user, as specified in the I<sudoers> file.
61 The real and effective uid and gid are set to match those of the
62 target user as specified in the passwd file and the group vector
63 is initialized based on the group file (unless the B<-P> option was
64 specified).  If the invoking user is root or if the target user is
65 the same as the invoking user, no password is required.  Otherwise,
66 B<sudo> requires that users authenticate themselves with a password
67 by default (NOTE: in the default configuration this is the user's
68 password, not the root password).  Once a user has been authenticated,
69 a time stamp is updated and the user may then use sudo without a
70 password for a short period of time (C<@timeout@> minutes unless
71 overridden in I<sudoers>).
72
73 When invoked as B<sudoedit>, the B<-e> option (described below),
74 is implied.
75
76 B<sudo> determines who is an authorized user by consulting the file
77 F<@sysconfdir@/sudoers>.  By running B<sudo> with the B<-v> option,
78 a user can update the time stamp without running a I<command>.  If
79 a password is required, B<sudo> will exit if the user's password
80 is not entered within a configurable time limit.  The default
81 password prompt timeout is C<@password_timeout@> minutes.
82
83 If a user who is not listed in the I<sudoers> file tries to run a
84 command via B<sudo>, mail is sent to the proper authorities, as
85 defined at configure time or in the I<sudoers> file (defaults to
86 C<@mailto@>).  Note that the mail will not be sent if an unauthorized
87 user tries to run sudo with the B<-l> or B<-v> option.  This allows
88 users to determine for themselves whether or not they are allowed
89 to use B<sudo>.
90
91 If B<sudo> is run by root and the C<SUDO_USER> environment variable
92 is set, B<sudo> will use this value to determine who the actual
93 user is.  This can be used by a user to log commands through sudo
94 even when a root shell has been invoked.  It also allows the B<-e>
95 option to remain useful even when being run via a sudo-run script or
96 program.  Note however, that the sudoers lookup is still done for
97 root, not the user specified by C<SUDO_USER>.
98
99 B<sudo> can log both successful and unsuccessful attempts (as well
100 as errors) to syslog(3), a log file, or both.  By default B<sudo>
101 will log via syslog(3) but this is changeable at configure time
102 or via the I<sudoers> file.
103
104 =head1 OPTIONS
105
106 B<sudo> accepts the following command line options:
107
108 =over 12
109
110 =item -A
111
112 Normally, if B<sudo> requires a password, it will read it from the
113 current terminal.  If the B<-A> (I<askpass>) option is specified,
114 a (possibly graphical) helper program is executed to read the
115 user's password and output the password to the standard output.  If
116 the C<SUDO_ASKPASS> environment variable is set, it specifies the
117 path to the helper program.  Otherwise, the value specified by the
118 I<askpass> option in L<sudoers(5)> is used.
119
120 =item -a I<type>
121
122 The B<-a> (I<authentication type>) option causes B<sudo> to use the
123 specified authentication type when validating the user, as allowed
124 by F</etc/login.conf>.  The system administrator may specify a list
125 of sudo-specific authentication methods by adding an "auth-sudo"
126 entry in F</etc/login.conf>.  This option is only available on systems
127 that support BSD authentication.
128
129 =item -b
130
131 The B<-b> (I<background>) option tells B<sudo> to run the given
132 command in the background.  Note that if you use the B<-b>
133 option you cannot use shell job control to manipulate the process.
134
135 =item -C I<fd>
136
137 Normally, B<sudo> will close all open file descriptors other than
138 standard input, standard output and standard error.  The B<-C>
139 (I<close from>) option allows the user to specify a starting point
140 above the standard error (file descriptor three).  Values less than
141 three are not permitted.  This option is only available if the
142 administrator has enabled the I<closefrom_override> option in
143 L<sudoers(5)>.
144
145 =item -c I<class>
146
147 The B<-c> (I<class>) option causes B<sudo> to run the specified command
148 with resources limited by the specified login class.  The I<class>
149 argument can be either a class name as defined in F</etc/login.conf>,
150 or a single '-' character.  Specifying a I<class> of C<-> indicates
151 that the command should be run restricted by the default login
152 capabilities for the user the command is run as.  If the I<class>
153 argument specifies an existing user class, the command must be run
154 as root, or the B<sudo> command must be run from a shell that is already
155 root.  This option is only available on systems with BSD login classes.
156
157 =item -E
158
159 The B<-E> (I<preserve> I<environment>) option will override the
160 I<env_reset> option in L<sudoers(5)>).  It is only
161 available when either the matching command has the C<SETENV> tag
162 or the I<setenv> option is set in L<sudoers(5)>.
163
164 =item -e
165
166 The B<-e> (I<edit>) option indicates that, instead of running
167 a command, the user wishes to edit one or more files.  In lieu
168 of a command, the string "sudoedit" is used when consulting
169 the I<sudoers> file.  If the user is authorized by I<sudoers>
170 the following steps are taken:
171
172 =over 4
173
174 =item 1.
175
176 Temporary copies are made of the files to be edited with the owner
177 set to the invoking user.
178
179 =item 2.
180
181 The editor specified by the C<SUDO_EDITOR>, C<VISUAL> or C<EDITOR>
182 environment variables is run to edit the temporary files.  If none
183 of C<SUDO_EDITOR>, C<VISUAL> or C<EDITOR> are set, the first program
184 listed in the I<editor> I<sudoers> variable is used.
185
186 =item 3.
187
188 If they have been modified, the temporary files are copied back to
189 their original location and the temporary versions are removed.
190
191 =back
192
193 If the specified file does not exist, it will be created.  Note
194 that unlike most commands run by B<sudo>, the editor is run with
195 the invoking user's environment unmodified.  If, for some reason,
196 B<sudo> is unable to update a file with its edited version, the
197 user will receive a warning and the edited copy will remain in a
198 temporary file.
199
200 =item -g I<group>
201
202 Normally, B<sudo> sets the primary group to the one specified by
203 the passwd database for the user the command is being run as (by
204 default, root).  The B<-g> (I<group>) option causes B<sudo> to run
205 the specified command with the primary group set to I<group>.  To
206 specify a I<gid> instead of a I<group name>, use I<#gid>.  When
207 running commands as a I<gid>, many shells require that the '#' be
208 escaped with a backslash ('\').  If no B<-u> option is specified,
209 the command will be run as the invoking user (not root).  In either
210 case, the primary group will be set to I<group>.
211
212 =item -H
213
214 The B<-H> (I<HOME>) option sets the C<HOME> environment variable
215 to the homedir of the target user (root by default) as specified
216 in passwd(5).  The default handling of the C<HOME> environment
217 variable depends on L<sudoers(5)> settings.  By default, B<sudo>
218 will set C<HOME> if I<env_reset> or I<always_set_home> are set, or
219 if I<set_home> is set and the B<-s> option is specified on the
220 command line.
221
222 =item -h
223
224 The B<-h> (I<help>) option causes B<sudo> to print a usage message and exit.
225
226 =item -i [command]
227
228 The B<-i> (I<simulate initial login>) option runs the shell specified
229 in the L<passwd(5)> entry of the target user as a login shell.  This
230 means that login-specific resource files such as C<.profile> or
231 C<.login> will be read by the shell.  If a command is specified,
232 it is passed to the shell for execution.  Otherwise, an interactive
233 shell is executed.  B<sudo> attempts to change to that user's home
234 directory before running the shell.  It also initializes the
235 environment, leaving I<DISPLAY> and I<TERM> unchanged, setting
236 I<HOME>, I<MAIL>, I<SHELL>, I<USER>, I<LOGNAME>, and I<PATH>, as well as
237 the contents of F</etc/environment> on Linux and AIX systems.
238 All other environment variables are removed.
239
240 =item -K
241
242 The B<-K> (sure I<kill>) option is like B<-k> except that it removes
243 the user's time stamp entirely and may not be used in conjunction
244 with a command or other option.  This option does not require a
245 password.
246
247 =item -k
248
249 When used by itself, the B<-k> (I<kill>) option to B<sudo> invalidates
250 the user's time stamp by setting the time on it to the Epoch.  The
251 next time B<sudo> is run a password will be required.  This option
252 does not require a password and was added to allow a user to revoke
253 B<sudo> permissions from a .logout file.
254
255 When used in conjunction with a command or an option that may require
256 a password, the B<-k> option will cause B<sudo> to ignore the user's
257 time stamp file.  As a result, B<sudo> will prompt for a password
258 (if one is required by I<sudoers>) and will not update the user's
259 time stamp file.
260
261 =item -L
262
263 The B<-L> (I<list> defaults) option will list the parameters that
264 may be set in a I<Defaults> line along with a short description for
265 each.  This option will be removed from a future version of B<sudo>.
266
267 =item -l[l] [I<command>]
268
269 If no I<command> is specified, the B<-l> (I<list>) option will list
270 the allowed (and forbidden) commands for the invoking user (or the
271 user specified by the B<-U> option) on the current host.  If a
272 I<command> is specified and is permitted by I<sudoers>, the
273 fully-qualified path to the command is displayed along with any
274 command line arguments.  If I<command> is specified but not allowed,
275 B<sudo> will exit with a status value of 1.  If the B<-l> option is
276 specified with an B<l> argument (i.e. B<-ll>), or if B<-l>
277 is specified multiple times, a longer list format is used.
278
279 =item -n
280
281 The B<-n> (I<non-interactive>) option prevents B<sudo> from prompting
282 the user for a password.  If a password is required for the command
283 to run, B<sudo> will display an error messages and exit.
284
285 =item -P
286
287 The B<-P> (I<preserve> I<group vector>) option causes B<sudo> to
288 preserve the invoking user's group vector unaltered.  By default,
289 B<sudo> will initialize the group vector to the list of groups the
290 target user is in.  The real and effective group IDs, however, are
291 still set to match the target user.
292
293 =item -p I<prompt>
294
295 The B<-p> (I<prompt>) option allows you to override the default
296 password prompt and use a custom one.  The following percent (`C<%>')
297 escapes are supported:
298
299 =over 4
300
301 =item C<%H>
302
303 expanded to the local host name including the domain name
304 (on if the machine's host name is fully qualified or the I<fqdn>
305 I<sudoers> option is set)
306
307 =item C<%h>
308
309 expanded to the local host name without the domain name
310
311 =item C<%p>
312
313 expanded to the user whose password is being asked for (respects the
314 I<rootpw>, I<targetpw> and I<runaspw> flags in I<sudoers>)
315
316 =item C<%U>
317
318 expanded to the login name of the user the command will
319 be run as (defaults to root)
320
321 =item C<%u>
322
323 expanded to the invoking user's login name
324
325 =item C<%%>
326
327 two consecutive C<%> characters are collapsed into a single C<%> character
328
329 =back
330
331 The prompt specified by the B<-p> option will override the system
332 password prompt on systems that support PAM unless the
333 I<passprompt_override> flag is disabled in I<sudoers>.
334
335 =item -r I<role>
336
337 The B<-r> (I<role>) option causes the new (SELinux) security context to
338 have the role specified by I<role>.
339
340 =item -S
341
342 The B<-S> (I<stdin>) option causes B<sudo> to read the password from
343 the standard input instead of the terminal device.  The password must
344 be followed by a newline character.
345
346 =item -s [command]
347
348 The B<-s> (I<shell>) option runs the shell specified by the I<SHELL>
349 environment variable if it is set or the shell as specified in
350 L<passwd(5)>.  If a command is specified, it is passed to the shell
351 for execution.  Otherwise, an interactive shell is executed.
352
353 =item -t I<type>
354
355 The B<-t> (I<type>) option causes the new (SELinux) security context to
356 have the type specified by I<type>.  If no type is specified, the default
357 type is derived from the specified role.
358
359 =item -U I<user>
360
361 The B<-U> (I<other user>) option is used in conjunction with the B<-l>
362 option to specify the user whose privileges should be listed.  Only
363 root or a user with B<sudo> C<ALL> on the current host may use this
364 option.
365
366 =item -u I<user>
367
368 The B<-u> (I<user>) option causes B<sudo> to run the specified
369 command as a user other than I<root>.  To specify a I<uid> instead
370 of a I<user name>, use I<#uid>.  When running commands as a I<uid>,
371 many shells require that the '#' be escaped with a backslash ('\').
372 Note that if the I<targetpw> Defaults option is set (see L<sudoers(5)>)
373 it is not possible to run commands with a uid not listed in the
374 password database.
375
376 =item -V
377
378 The B<-V> (I<version>) option causes B<sudo> to print the version
379 number and exit.  If the invoking user is already root the B<-V>
380 option will print out a list of the defaults B<sudo> was compiled
381 with as well as the machine's local network addresses.
382
383 =item -v
384
385 If given the B<-v> (I<validate>) option, B<sudo> will update the
386 user's time stamp, prompting for the user's password if necessary.
387 This extends the B<sudo> timeout for another C<@timeout@> minutes
388 (or whatever the timeout is set to in I<sudoers>) but does not run
389 a command.
390
391 =item --
392
393 The B<--> option indicates that B<sudo> should stop processing command
394 line arguments.
395
396 =back
397
398 Environment variables to be set for the command may also be passed
399 on the command line in the form of B<VAR>=I<value>, e.g.
400 B<LD_LIBRARY_PATH>=I</usr/local/pkg/lib>.  Variables passed on the
401 command line are subject to the same restrictions as normal environment
402 variables with one important exception.  If the I<setenv> option
403 is set in I<sudoers>, the command to be run has the C<SETENV> tag
404 set or the command matched is C<ALL>, the user may set variables
405 that would overwise be forbidden.  See L<sudoers(5)> for more information.
406
407 =head1 RETURN VALUES
408
409 Upon successful execution of a program, the exit status from B<sudo>
410 will simply be the exit status of the program that was executed.
411
412 Otherwise, B<sudo> quits with an exit value of 1 if there is a
413 configuration/permission problem or if B<sudo> cannot execute the
414 given command.  In the latter case the error string is printed to
415 stderr.  If B<sudo> cannot L<stat(2)> one or more entries in the user's
416 C<PATH> an error is printed on stderr.  (If the directory does not
417 exist or if it is not really a directory, the entry is ignored and
418 no error is printed.)  This should not happen under normal
419 circumstances.  The most common reason for L<stat(2)> to return
420 "permission denied" is if you are running an automounter and one
421 of the directories in your C<PATH> is on a machine that is currently
422 unreachable.
423
424 =head1 SECURITY NOTES
425
426 B<sudo> tries to be safe when executing external commands.
427
428 There are two distinct ways to deal with environment variables.
429 By default, the I<env_reset> I<sudoers> option is enabled.
430 This causes commands to be executed with a minimal environment
431 containing C<TERM>, C<PATH>, C<HOME>, C<SHELL>, C<LOGNAME>, C<USER>
432 and C<USERNAME> in addition to variables from the invoking process
433 permitted by the I<env_check> and I<env_keep> I<sudoers> options.
434 There is effectively a whitelist for environment variables.
435
436 If, however, the I<env_reset> option is disabled in I<sudoers>, any
437 variables not explicitly denied by the I<env_check> and I<env_delete>
438 options are inherited from the invoking process.  In this case,
439 I<env_check> and I<env_delete> behave like a blacklist.  Since it
440 is not possible to blacklist all potentially dangerous environment
441 variables, use of the default I<env_reset> behavior is encouraged.
442
443 In all cases, environment variables with a value beginning with
444 C<()> are removed as they could be interpreted as B<bash> functions.
445 The list of environment variables that B<sudo> allows or denies is
446 contained in the output of C<sudo -V> when run as root.
447
448 Note that the dynamic linker on most operating systems will remove
449 variables that can control dynamic linking from the environment of
450 setuid executables, including B<sudo>.  Depending on the operating
451 system this may include C<_RLD*>, C<DYLD_*>, C<LD_*>, C<LDR_*>,
452 C<LIBPATH>, C<SHLIB_PATH>, and others.  These type of variables are
453 removed from the environment before B<sudo> even begins execution
454 and, as such, it is not possible for B<sudo> to preserve them.
455
456 To prevent command spoofing, B<sudo> checks "." and "" (both denoting
457 current directory) last when searching for a command in the user's
458 PATH (if one or both are in the PATH).  Note, however, that the
459 actual C<PATH> environment variable is I<not> modified and is passed
460 unchanged to the program that B<sudo> executes.
461
462 B<sudo> will check the ownership of its time stamp directory
463 (F<@timedir@> by default) and ignore the directory's contents if
464 it is not owned by root or if it is writable by a user other than
465 root.  On systems that allow non-root users to give away files via
466 L<chown(2)>, if the time stamp directory is located in a directory
467 writable by anyone (e.g., F</tmp>), it is possible for a user to
468 create the time stamp directory before B<sudo> is run.  However,
469 because B<sudo> checks the ownership and mode of the directory and
470 its contents, the only damage that can be done is to "hide" files
471 by putting them in the time stamp dir.  This is unlikely to happen
472 since once the time stamp dir is owned by root and inaccessible by
473 any other user, the user placing files there would be unable to get
474 them back out.  To get around this issue you can use a directory
475 that is not world-writable for the time stamps (F</var/adm/sudo> for
476 instance) or create F<@timedir@> with the appropriate owner (root)
477 and permissions (0700) in the system startup files.
478
479 B<sudo> will not honor time stamps set far in the future.
480 Timestamps with a date greater than current_time + 2 * C<TIMEOUT>
481 will be ignored and sudo will log and complain.  This is done to
482 keep a user from creating his/her own time stamp with a bogus
483 date on systems that allow users to give away files.
484
485 On systems where the boot time is available, B<sudo> will also not
486 honor time stamps from before the machine booted.
487
488 Since time stamp files live in the file system, they can outlive a
489 user's login session.  As a result, a user may be able to login,
490 run a command with B<sudo> after authenticating, logout, login
491 again, and run B<sudo> without authenticating so long as the time
492 stamp file's modification time is within C<@timeout@> minutes (or
493 whatever the timeout is set to in I<sudoers>).  When the I<tty_tickets>
494 option is enabled in I<sudoers>, the time stamp has per-tty granularity
495 but still may outlive the user's session.  On Linux systems where
496 the devpts filesystem is used, Solaris systems with the devices
497 filesystem, as well as other systems that utilize a devfs filesystem
498 that monotonically increase the inode number of devices as they are
499 created (such as Mac OS X), B<sudo> is able to determine when a
500 tty-based time stamp file is stale and will ignore it.  Administrators
501 should not rely on this feature as it is not universally available.
502
503 Please note that B<sudo> will normally only log the command it
504 explicitly runs.  If a user runs a command such as C<sudo su> or
505 C<sudo sh>, subsequent commands run from that shell will I<not> be
506 logged, nor will B<sudo>'s access control affect them.  The same
507 is true for commands that offer shell escapes (including most
508 editors).  Because of this, care must be taken when giving users
509 access to commands via B<sudo> to verify that the command does not
510 inadvertently give the user an effective root shell.  For more
511 information, please see the C<PREVENTING SHELL ESCAPES> section in
512 L<sudoers(5)>.
513
514 =head1 ENVIRONMENT
515
516 B<sudo> utilizes the following environment variables:
517
518 =over 16
519
520 =item C<EDITOR>
521
522 Default editor to use in B<-e> (sudoedit) mode if neither C<SUDO_EDITOR>
523 nor C<VISUAL> is set
524
525 =item C<MAIL>
526
527 In B<-i> mode or when I<env_reset> is enabled in I<sudoers>, set
528 to the mail spool of the target user
529
530 =item C<HOME>
531
532 Set to the home directory of the target user if B<-i> or B<-H> are
533 specified, I<env_reset> or I<always_set_home> are set in I<sudoers>,
534 or when the B<-s> option is specified and I<set_home> is set in
535 I<sudoers>
536
537 =item C<PATH>
538
539 Set to a sane value if the I<secure_path> sudoers option is set.
540
541 =item C<SHELL>
542
543 Used to determine shell to run with C<-s> option
544
545 =item C<SUDO_ASKPASS>
546
547 Specifies the path to a helper program used to read the password
548 if no terminal is available or if the C<-A> option is specified.
549
550 =item C<SUDO_COMMAND>
551
552 Set to the command run by sudo
553
554 =item C<SUDO_EDITOR>
555
556 Default editor to use in B<-e> (sudoedit) mode
557
558 =item C<SUDO_GID>
559
560 Set to the group ID of the user who invoked sudo
561
562 =item C<SUDO_PROMPT>
563
564 Used as the default password prompt
565
566 =item C<SUDO_PS1>
567
568 If set, C<PS1> will be set to its value for the program being run
569
570 =item C<SUDO_UID>
571
572 Set to the user ID of the user who invoked sudo
573
574 =item C<SUDO_USER>
575
576 Set to the login of the user who invoked sudo
577
578 =item C<USER>
579
580 Set to the target user (root unless the B<-u> option is specified)
581
582 =item C<VISUAL>
583
584 Default editor to use in B<-e> (sudoedit) mode if C<SUDO_EDITOR>
585 is not set
586
587 =back
588
589 =head1 FILES
590
591 =over 24
592
593 =item F<@sysconfdir@/sudoers>
594
595 List of who can run what
596
597 =item F<@timedir@>
598
599 Directory containing time stamps
600
601 =item F</etc/environment>
602
603 Initial environment for B<-i> mode on Linux and AIX
604
605 =back
606
607 =head1 EXAMPLES
608
609 Note: the following examples assume suitable L<sudoers(5)> entries.
610
611 To get a file listing of an unreadable directory:
612
613  $ sudo ls /usr/local/protected
614
615 To list the home directory of user yaz on a machine where the
616 file system holding ~yaz is not exported as root:
617
618  $ sudo -u yaz ls ~yaz
619
620 To edit the F<index.html> file as user www:
621
622  $ sudo -u www vi ~www/htdocs/index.html
623
624 To view system logs only accessible to root and users in the adm group:
625
626  $ sudo -g adm view /var/log/syslog
627
628 To run an editor as jim with a different primary group:
629
630  $ sudo -u jim -g audio vi ~jim/sound.txt
631
632 To shutdown a machine:
633
634  $ sudo shutdown -r +15 "quick reboot"
635
636 To make a usage listing of the directories in the /home
637 partition.  Note that this runs the commands in a sub-shell
638 to make the C<cd> and file redirection work.
639
640  $ sudo sh -c "cd /home ; du -s * | sort -rn > USAGE"
641
642 =head1 SEE ALSO
643
644 L<grep(1)>, L<su(1)>, L<stat(2)>,
645 L<login_cap(3)>,
646 L<passwd(5)>, L<sudoers(5)>, L<visudo(8)>
647
648 =head1 AUTHORS
649
650 Many people have worked on B<sudo> over the years; this
651 version consists of code written primarily by:
652
653         Todd C. Miller
654
655 See the HISTORY file in the B<sudo> distribution or visit
656 http://www.sudo.ws/sudo/history.html for a short history
657 of B<sudo>.
658
659 =head1 CAVEATS
660
661 There is no easy way to prevent a user from gaining a root shell
662 if that user is allowed to run arbitrary commands via B<sudo>.
663 Also, many programs (such as editors) allow the user to run commands
664 via shell escapes, thus avoiding B<sudo>'s checks.  However, on
665 most systems it is possible to prevent shell escapes with B<sudo>'s
666 I<noexec> functionality.  See the L<sudoers(5)> manual
667 for details.
668
669 It is not meaningful to run the C<cd> command directly via sudo, e.g.,
670
671  $ sudo cd /usr/local/protected
672
673 since when the command exits the parent process (your shell) will
674 still be the same.  Please see the EXAMPLES section for more information.
675
676 If users have sudo C<ALL> there is nothing to prevent them from
677 creating their own program that gives them a root shell regardless
678 of any '!' elements in the user specification.
679
680 Running shell scripts via B<sudo> can expose the same kernel bugs that
681 make setuid shell scripts unsafe on some operating systems (if your OS
682 has a /dev/fd/ directory, setuid shell scripts are generally safe).
683
684 =head1 BUGS
685
686 If you feel you have found a bug in B<sudo>, please submit a bug report
687 at http://www.sudo.ws/sudo/bugs/
688
689 =head1 SUPPORT
690
691 Limited free support is available via the sudo-users mailing list,
692 see http://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or
693 search the archives.
694
695 =head1 DISCLAIMER
696
697 B<sudo> is provided ``AS IS'' and any express or implied warranties,
698 including, but not limited to, the implied warranties of merchantability
699 and fitness for a particular purpose are disclaimed.  See the LICENSE
700 file distributed with B<sudo> or http://www.sudo.ws/sudo/license.html
701 for complete details.