1SUDO(8)                   BSD System Manager's Manual                  SUDO(8)
2

NAME

4     sudo, sudoedit — execute a command as another user
5

SYNOPSIS

7     sudo -h | -K | -k | -V
8     sudo -v [-ABkNnS] [-g group] [-h host] [-p prompt] [-u user]
9     sudo -l [-ABkNnS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
10          [command [arg ...]]
11     sudo [-ABbEHnPS] [-C num] [-D directory] [-g group] [-h host] [-p prompt]
12          [-R directory] [-r role] [-t type] [-T timeout] [-u user]
13          [VAR=value] [-i | -s] [command [arg ...]]
14     sudoedit [-ABkNnS] [-C num] [-D directory] [-g group] [-h host]
15          [-p prompt] [-R directory] [-r role] [-t type] [-T timeout]
16          [-u user] file ...
17

DESCRIPTION

19     sudo allows a permitted user to execute a command as the superuser or an‐
20     other user, as specified by the security policy.  The invoking user's
21     real (not effective) user-ID is used to determine the user name with
22     which to query the security policy.
23
24     sudo supports a plugin architecture for security policies, auditing, and
25     input/output logging.  Third parties can develop and distribute their own
26     plugins to work seamlessly with the sudo front-end.  The default security
27     policy is sudoers, which is configured via the file /etc/sudoers, or via
28     LDAP.  See the Plugins section for more information.
29
30     The security policy determines what privileges, if any, a user has to run
31     sudo.  The policy may require that users authenticate themselves with a
32     password or another authentication mechanism.  If authentication is re‐
33     quired, sudo will exit if the user's password is not entered within a
34     configurable time limit.  This limit is policy-specific; the default
35     password prompt timeout for the sudoers security policy is 5 minutes.
36
37     Security policies may support credential caching to allow the user to run
38     sudo again for a period of time without requiring authentication.  By de‐
39     fault, the sudoers policy caches credentials on a per-terminal basis for
40     5 minutes.  See the timestamp_type and timestamp_timeout options in
41     sudoers(5) for more information.  By running sudo with the -v option, a
42     user can update the cached credentials without running a command.
43
44     On systems where sudo is the primary method of gaining superuser privi‐
45     leges, it is imperative to avoid syntax errors in the security policy
46     configuration files.  For the default security policy, sudoers(5),
47     changes to the configuration files should be made using the visudo(8)
48     utility which will ensure that no syntax errors are introduced.
49
50     When invoked as sudoedit, the -e option (described below), is implied.
51
52     Security policies and audit plugins may log successful and failed at‐
53     tempts to run sudo.  If an I/O plugin is configured, the running
54     command's input and output may be logged as well.
55
56     The options are as follows:
57
58     -A, --askpass
59             Normally, if sudo requires a password, it will read it from the
60             user's terminal.  If the -A (askpass) option is specified, a
61             (possibly graphical) helper program is executed to read the
62             user's password and output the password to the standard output.
63             If the SUDO_ASKPASS environment variable is set, it specifies the
64             path to the helper program.  Otherwise, if sudo.conf(5) contains
65             a line specifying the askpass program, that value will be used.
66             For example:
67
68                 # Path to askpass helper program
69                 Path askpass /usr/X11R6/bin/ssh-askpass
70
71             If no askpass program is available, sudo will exit with an error.
72
73     -B, --bell
74             Ring the bell as part of the password prompt when a terminal is
75             present.  This option has no effect if an askpass program is
76             used.
77
78     -b, --background
79             Run the given command in the background.  It is not possible to
80             use shell job control to manipulate background processes started
81             by sudo.  Most interactive commands will fail to work properly in
82             background mode.
83
84     -C num, --close-from=num
85             Close all file descriptors greater than or equal to num before
86             executing a command.  Values less than three are not permitted.
87             By default, sudo will close all open file descriptors other than
88             standard input, standard output, and standard error when execut‐
89             ing a command.  The security policy may restrict the user's abil‐
90             ity to use this option.  The sudoers policy only permits use of
91             the -C option when the administrator has enabled the
92             closefrom_override option.
93
94     -D directory, --chdir=directory
95             Run the command in the specified directory instead of the current
96             working directory.  The security policy may return an error if
97             the user does not have permission to specify the working direc‐
98             tory.
99
100     -E, --preserve-env
101             Indicates to the security policy that the user wishes to preserve
102             their existing environment variables.  The security policy may
103             return an error if the user does not have permission to preserve
104             the environment.
105
106     --preserve-env=list
107             Indicates to the security policy that the user wishes to add the
108             comma-separated list of environment variables to those preserved
109             from the user's environment.  The security policy may return an
110             error if the user does not have permission to preserve the envi‐
111             ronment.  This option may be specified multiple times.
112
113     -e, --edit
114             Edit one or more files instead of running a command.  In lieu of
115             a path name, the string "sudoedit" is used when consulting the
116             security policy.  If the user is authorized by the policy, the
117             following steps are taken:
118
119             1.   Temporary copies are made of the files to be edited with the
120                  owner set to the invoking user.
121
122             2.   The editor specified by the policy is run to edit the tempo‐
123                  rary files.  The sudoers policy uses the SUDO_EDITOR, VISUAL
124                  and EDITOR environment variables (in that order).  If none
125                  of SUDO_EDITOR, VISUAL or EDITOR are set, the first program
126                  listed in the editor sudoers(5) option is used.
127
128             3.   If they have been modified, the temporary files are copied
129                  back to their original location and the temporary versions
130                  are removed.
131
132             To help prevent the editing of unauthorized files, the following
133             restrictions are enforced unless explicitly allowed by the secu‐
134             rity policy:
135
136              Symbolic links may not be edited (version 1.8.15 and higher).
137
138              Symbolic links along the path to be edited are not followed
139                 when the parent directory is writable by the invoking user
140                 unless that user is root (version 1.8.16 and higher).
141
142              Files located in a directory that is writable by the invoking
143                 user may not be edited unless that user is root (version
144                 1.8.16 and higher).
145
146             Users are never allowed to edit device special files.
147
148             If the specified file does not exist, it will be created.  Unlike
149             most commands run by sudo, the editor is run with the invoking
150             user's environment unmodified.  If the temporary file becomes
151             empty after editing, the user will be prompted before it is in‐
152             stalled.  If, for some reason, sudo is unable to update a file
153             with its edited version, the user will receive a warning and the
154             edited copy will remain in a temporary file.
155
156     -g group, --group=group
157             Run the command with the primary group set to group instead of
158             the primary group specified by the target user's password data‐
159             base entry.  The group may be either a group name or a numeric
160             group-ID (GID) prefixed with the ‘#’ character (e.g., ‘#0’ for
161             GID 0).  When running a command as a GID, many shells require
162             that the ‘#’ be escaped with a backslash (‘\’).  If no -u option
163             is specified, the command will be run as the invoking user.  In
164             either case, the primary group will be set to group.  The sudoers
165             policy permits any of the target user's groups to be specified
166             via the -g option as long as the -P option is not in use.
167
168     -H, --set-home
169             Request that the security policy set the HOME environment vari‐
170             able to the home directory specified by the target user's pass‐
171             word database entry.  Depending on the policy, this may be the
172             default behavior.
173
174     -h, --help
175             Display a short help message to the standard output and exit.
176
177     -h host, --host=host
178             Run the command on the specified host if the security policy
179             plugin supports remote commands. The sudoers plugin does not cur‐
180             rently support running remote commands. This may also be used in
181             conjunction with the -l option to list a user's privileges for
182             the remote host.
183
184     -i, --login
185             Run the shell specified by the target user's password database
186             entry as a login shell.  This means that login-specific resource
187             files such as .profile, .bash_profile, or .login will be read by
188             the shell.  If a command is specified, it is passed to the shell
189             as a simple command using the -c option.  The command and any
190             args are concatenated, separated by spaces, after escaping each
191             character (including white space) with a backslash (‘\’) except
192             for alphanumerics, underscores, hyphens, and dollar signs.  If no
193             command is specified, an interactive shell is executed.  sudo at‐
194             tempts to change to that user's home directory before running the
195             shell.  The command is run with an environment similar to the one
196             a user would receive at log in.  Most shells behave differently
197             when a command is specified as compared to an interactive ses‐
198             sion; consult the shell's manual for details.  The Command
199             environment section in the sudoers(5) manual documents how the -i
200             option affects the environment in which a command is run when the
201             sudoers policy is in use.
202
203     -K, --remove-timestamp
204             Similar to the -k option, except that it removes every cached
205             credential for the user, regardless of the terminal or parent
206             process ID.  The next time sudo is run, a password must be en‐
207             tered if the security policy requires authentication.  It is not
208             possible to use the -K option in conjunction with a command or
209             other option.  This option does not require a password.  Not all
210             security policies support credential caching.
211
212     -k, --reset-timestamp
213             When used without a command, invalidates the user's cached cre‐
214             dentials for the current session.  The next time sudo is run in
215             the session, a password must be entered if the security policy
216             requires authentication.  By default, the sudoers policy uses a
217             separate record in the credential cache for each terminal (or
218             parent process ID if no terminal is present).  This prevents the
219             -k option from interfering with sudo commands run in a different
220             terminal session.  See the timestamp_type option in sudoers(5)
221             for more information.  This option does not require a password,
222             and was added to allow a user to revoke sudo permissions from a
223             .logout file.
224
225             When used in conjunction with a command or an option that may re‐
226             quire a password, this option will cause sudo to ignore the
227             user's cached credentials.  As a result, sudo will prompt for a
228             password (if one is required by the security policy) and will not
229             update the user's cached credentials.
230
231             Not all security policies support credential caching.
232
233     -l, --list
234             If no command is specified, list the privileges for the invoking
235             user (or the user specified by the -U option) on the current
236             host.  A longer list format is used if this option is specified
237             multiple times and the security policy supports a verbose output
238             format.
239
240             If a command is specified and is permitted by the security pol‐
241             icy, the fully-qualified path to the command is displayed along
242             with any args. If a command is specified but not allowed by the
243             policy, sudo will exit with a status value of 1.
244
245     -N, --no-update
246             Do not update the user's cached credentials, even if the user
247             successfully authenticates.  Unlike the -k flag, existing cached
248             credentials are used if they are valid.  To detect when the
249             user's cached credentials are valid (or when no authentication is
250             required), the following can be used:
251                   sudo -Nnv
252
253             Not all security policies support credential caching.
254
255     -n, --non-interactive
256             Avoid prompting the user for input of any kind.  If a password is
257             required for the command to run, sudo will display an error mes‐
258             sage and exit.
259
260     -P, --preserve-groups
261             Preserve the invoking user's group vector unaltered.  By default,
262             the sudoers policy will initialize the group vector to the list
263             of groups the target user is a member of.  The real and effective
264             group-IDs, however, are still set to match the target user.
265
266     -p prompt, --prompt=prompt
267             Use a custom password prompt with optional escape sequences.  The
268             following percent (‘%’) escape sequences are supported by the
269             sudoers policy:
270
271             %H  expanded to the host name including the domain name (only if
272                 the machine's host name is fully qualified or the fqdn option
273                 is set in sudoers(5))
274
275             %h  expanded to the local host name without the domain name
276
277             %p  expanded to the name of the user whose password is being re‐
278                 quested (respects the rootpw, targetpw, and runaspw flags in
279                 sudoers(5))
280
281             %U  expanded to the login name of the user the command will be
282                 run as (defaults to root unless the -u option is also speci‐
283                 fied)
284
285             %u  expanded to the invoking user's login name
286
287             %%  two consecutive ‘%’ characters are collapsed into a single
288                 ‘%’ character
289
290             The custom prompt will override the default prompt specified by
291             either the security policy or the SUDO_PROMPT environment vari‐
292             able.  On systems that use PAM, the custom prompt will also over‐
293             ride the prompt specified by a PAM module unless the
294             passprompt_override flag is disabled in sudoers.
295
296     -R directory, --chroot=directory
297             Change to the specified root directory (see chroot(8)) before
298             running the command.  The security policy may return an error if
299             the user does not have permission to specify the root directory.
300
301     -r role, --role=role
302             Run the command with an SELinux security context that includes
303             the specified role.
304
305     -S, --stdin
306             Write the prompt to the standard error and read the password from
307             the standard input instead of using the terminal device.
308
309     -s, --shell
310             Run the shell specified by the SHELL environment variable if it
311             is set or the shell specified by the invoking user's password
312             database entry.  If a command is specified, it is passed to the
313             shell as a simple command using the -c option.  The command and
314             any args are concatenated, separated by spaces, after escaping
315             each character (including white space) with a backslash (‘\’) ex‐
316             cept for alphanumerics, underscores, hyphens, and dollar signs.
317             If no command is specified, an interactive shell is executed.
318             Most shells behave differently when a command is specified as
319             compared to an interactive session; consult the shell's manual
320             for details.
321
322     -t type, --type=type
323             Run the command with an SELinux security context that includes
324             the specified type.  If no type is specified, the default type is
325             derived from the role.
326
327     -U user, --other-user=user
328             Used in conjunction with the -l option to list the privileges for
329             user instead of for the invoking user.  The security policy may
330             restrict listing other users' privileges.  When using the sudoers
331             policy, the -U option is restricted to the root user and users
332             with either the “list” priviege for the specified user or the
333             ability to run any command as root or user on the current host.
334
335     -T timeout, --command-timeout=timeout
336             Used to set a timeout for the command.  If the timeout expires
337             before the command has exited, the command will be terminated.
338             The security policy may restrict the user's ability to set time‐
339             outs.  The sudoers policy requires that user-specified timeouts
340             be explicitly enabled.
341
342     -u user, --user=user
343             Run the command as a user other than the default target user
344             (usually root).  The user may be either a user name or a numeric
345             user-ID (UID) prefixed with the ‘#’ character (e.g., ‘#0’ for UID
346             0).  When running commands as a UID, many shells require that the
347             ‘#’ be escaped with a backslash (‘\’).  Some security policies
348             may restrict UIDs to those listed in the password database.  The
349             sudoers policy allows UIDs that are not in the password database
350             as long as the targetpw option is not set.  Other security poli‐
351             cies may not support this.
352
353     -V, --version
354             Print the sudo version string as well as the version string of
355             any configured plugins.  If the invoking user is already root,
356             the -V option will display the options passed to configure when
357             sudo was built; plugins may display additional information such
358             as default options.
359
360     -v, --validate
361             Update the user's cached credentials, authenticating the user if
362             necessary.  For the sudoers plugin, this extends the sudo timeout
363             for another 5 minutes by default, but does not run a command.
364             Not all security policies support cached credentials.
365
366     --      The -- is used to delimit the end of the sudo options.  Subse‐
367             quent options are passed to the command.
368
369     Options that take a value may only be specified once unless otherwise in‐
370     dicated in the description.  This is to help guard against problems
371     caused by poorly written scripts that invoke sudo with user-controlled
372     input.
373
374     Environment variables to be set for the command may also be passed as op‐
375     tions to sudo in the form VAR=value, for example
376     LD_LIBRARY_PATH=/usr/local/pkg/lib.  Environment variables may be subject
377     to restrictions imposed by the security policy plugin.  The sudoers pol‐
378     icy subjects environment variables passed as options to the same restric‐
379     tions as existing environment variables with one important difference.
380     If the setenv option is set in sudoers, the command to be run has the
381     SETENV tag set or the command matched is ALL, the user may set variables
382     that would otherwise be forbidden.  See sudoers(5) for more information.
383

COMMAND EXECUTION

385     When sudo executes a command, the security policy specifies the execution
386     environment for the command.  Typically, the real and effective user and
387     group and IDs are set to match those of the target user, as specified in
388     the password database, and the group vector is initialized based on the
389     group database (unless the -P option was specified).
390
391     The following parameters may be specified by security policy:
392
393     real and effective user-ID
394
395     real and effective group-ID
396
397     supplementary group-IDs
398
399     the environment list
400
401     current working directory
402
403     file creation mode mask (umask)
404
405     SELinux role and type
406
407     scheduling priority (aka nice value)
408
409   Process model
410     There are two distinct ways sudo can run a command.
411
412     If an I/O logging plugin is configured to log terminal I/O, or if the se‐
413     curity policy explicitly requests it, a new pseudo-terminal (“pty”) is
414     allocated and fork(2) is used to create a second sudo process, referred
415     to as the monitor.  The monitor creates a new terminal session with it‐
416     self as the leader and the pty as its controlling terminal, calls fork(2)
417     again, sets up the execution environment as described above, and then
418     uses the execve(2) system call to run the command in the child process.
419     The monitor exists to relay job control signals between the user's termi‐
420     nal and the pty the command is being run in.  This makes it possible to
421     suspend and resume the command normally.  Without the monitor, the
422     command would be in what POSIX terms an “orphaned process group” and it
423     would not receive any job control signals from the kernel.  When the
424     command exits or is terminated by a signal, the monitor passes the
425     command's exit status to the main sudo process and exits.  After receiv‐
426     ing the command's exit status, the main sudo process passes the command's
427     exit status to the security policy's close function, as well as the close
428     function of any configured audit plugin, and exits.
429
430     If no pty is used, sudo calls fork(2), sets up the execution environment
431     as described above, and uses the execve(2) system call to run the command
432     in the child process.  The main sudo process waits until the command has
433     completed, then passes the command's exit status to the security policy's
434     close function, as well as the close function of any configured audit
435     plugins, and exits.  As a special case, if the policy plugin does not de‐
436     fine a close function, sudo will execute the command directly instead of
437     calling fork(2) first.  The sudoers policy plugin will only define a
438     close function when I/O logging is enabled, a pty is required, an SELinux
439     role is specified, the command has an associated timeout, or the
440     pam_session or pam_setcred options are enabled.  Both pam_session and
441     pam_setcred are enabled by default on systems using PAM.
442
443     On systems that use PAM, the security policy's close function is respon‐
444     sible for closing the PAM session.  It may also log the command's exit
445     status.
446
447   Signal handling
448     When the command is run as a child of the sudo process, sudo will relay
449     signals it receives to the command.  The SIGINT and SIGQUIT signals are
450     only relayed when the command is being run in a new pty or when the sig‐
451     nal was sent by a user process, not the kernel.  This prevents the
452     command from receiving SIGINT twice each time the user enters control-C.
453     Some signals, such as SIGSTOP and SIGKILL, cannot be caught and thus will
454     not be relayed to the command.  As a general rule, SIGTSTP should be used
455     instead of SIGSTOP when you wish to suspend a command being run by sudo.
456
457     As a special case, sudo will not relay signals that were sent by the
458     command it is running.  This prevents the command from accidentally
459     killing itself.  On some systems, the reboot(8) utility sends SIGTERM to
460     all non-system processes other than itself before rebooting the system.
461     This prevents sudo from relaying the SIGTERM signal it received back to
462     reboot(8), which might then exit before the system was actually rebooted,
463     leaving it in a half-dead state similar to single user mode.  Note, how‐
464     ever, that this check only applies to the command run by sudo and not any
465     other processes that the command may create.  As a result, running a
466     script that calls reboot(8) or shutdown(8) via sudo may cause the system
467     to end up in this undefined state unless the reboot(8) or shutdown(8) are
468     run using the exec() family of functions instead of system() (which in‐
469     terposes a shell between the command and the calling process).
470
471   Plugins
472     Plugins may be specified via Plugin directives in the sudo.conf(5) file.
473     They may be loaded as dynamic shared objects (on systems that support
474     them), or compiled directly into the sudo binary.  If no sudo.conf(5)
475     file is present, or if it doesn't contain any Plugin lines, sudo will use
476     sudoers(5) for the policy, auditing, and I/O logging plugins.  See the
477     sudo.conf(5) manual for details of the /etc/sudo.conf file and the
478     sudo_plugin(5) manual for more information about the sudo plugin archi‐
479     tecture.
480

EXIT VALUE

482     Upon successful execution of a command, the exit status from sudo will be
483     the exit status of the program that was executed.  If the command termi‐
484     nated due to receipt of a signal, sudo will send itself the same signal
485     that terminated the command.
486
487     If the -l option was specified without a command, sudo will exit with a
488     value of 0 if the user is allowed to run sudo and they authenticated suc‐
489     cessfully (as required by the security policy).  If a command is speci‐
490     fied with the -l option, the exit value will only be 0 if the command is
491     permitted by the security policy, otherwise it will be 1.
492
493     If there is an authentication failure, a configuration/permission prob‐
494     lem, or if the given command cannot be executed, sudo exits with a value
495     of 1.  In the latter case, the error string is printed to the standard
496     error.  If sudo cannot stat(2) one or more entries in the user's PATH, an
497     error is printed to the standard error.  (If the directory does not exist
498     or if it is not really a directory, the entry is ignored and no error is
499     printed.)  This should not happen under normal circumstances.  The most
500     common reason for stat(2) to return “permission denied” is if you are
501     running an automounter and one of the directories in your PATH is on a
502     machine that is currently unreachable.
503

SECURITY NOTES

505     sudo tries to be safe when executing external commands.
506
507     To prevent command spoofing, sudo checks "." and "" (both denoting cur‐
508     rent directory) last when searching for a command in the user's PATH (if
509     one or both are in the PATH).  Depending on the security policy, the
510     user's PATH environment variable may be modified, replaced, or passed un‐
511     changed to the program that sudo executes.
512
513     Users should never be granted sudo privileges to execute files that are
514     writable by the user or that reside in a directory that is writable by
515     the user.  If the user can modify or replace the command there is no way
516     to limit what additional commands they can run.
517
518     By default, sudo will only log the command it explicitly runs.  If a user
519     runs a command such as ‘sudo su’ or ‘sudo sh’, subsequent commands run
520     from that shell are not subject to sudo's security policy.  The same is
521     true for commands that offer shell escapes (including most editors).  If
522     I/O logging is enabled, subsequent commands will have their input and/or
523     output logged, but there will not be traditional logs for those commands.
524     Because of this, care must be taken when giving users access to commands
525     via sudo to verify that the command does not inadvertently give the user
526     an effective root shell.  For information on ways to address this, see
527     the Preventing shell escapes section in sudoers(5).
528
529     To prevent the disclosure of potentially sensitive information, sudo dis‐
530     ables core dumps by default while it is executing (they are re-enabled
531     for the command that is run).  This historical practice dates from a time
532     when most operating systems allowed set-user-ID processes to dump core by
533     default.  To aid in debugging sudo crashes, you may wish to re-enable
534     core dumps by setting “disable_coredump” to false in the sudo.conf(5)
535     file as follows:
536
537         Set disable_coredump false
538
539     See the sudo.conf(5) manual for more information.
540

ENVIRONMENT

542     sudo utilizes the following environment variables.  The security policy
543     has control over the actual content of the command's environment.
544
545     EDITOR           Default editor to use in -e (sudoedit) mode if neither
546                      SUDO_EDITOR nor VISUAL is set.
547
548     MAIL             Set to the mail spool of the target user when the -i op‐
549                      tion is specified, or when env_reset is enabled in
550                      sudoers (unless MAIL is present in the env_keep list).
551
552     HOME             Set to the home directory of the target user when the -i
553                      or -H options are specified, when the -s option is spec‐
554                      ified and set_home is set in sudoers, when
555                      always_set_home is enabled in sudoers, or when env_reset
556                      is enabled in sudoers and HOME is not present in the
557                      env_keep list.
558
559     LOGNAME          Set to the login name of the target user when the -i op‐
560                      tion is specified, when the set_logname option is en‐
561                      abled in sudoers, or when the env_reset option is en‐
562                      abled in sudoers (unless LOGNAME is present in the
563                      env_keep list).
564
565     PATH             May be overridden by the security policy.
566
567     SHELL            Used to determine shell to run with -s option.
568
569     SUDO_ASKPASS     Specifies the path to a helper program used to read the
570                      password if no terminal is available or if the -A option
571                      is specified.
572
573     SUDO_COMMAND     Set to the command run by sudo, including any args. The
574                      args are truncated at 4096 characters to prevent a po‐
575                      tential execution error.
576
577     SUDO_EDITOR      Default editor to use in -e (sudoedit) mode.
578
579     SUDO_GID         Set to the group-ID of the user who invoked sudo.
580
581     SUDO_PROMPT      Used as the default password prompt unless the -p option
582                      was specified.
583
584     SUDO_PS1         If set, PS1 will be set to its value for the program be‐
585                      ing run.
586
587     SUDO_UID         Set to the user-ID of the user who invoked sudo.
588
589     SUDO_USER        Set to the login name of the user who invoked sudo.
590
591     USER             Set to the same value as LOGNAME, described above.
592
593     VISUAL           Default editor to use in -e (sudoedit) mode if
594                      SUDO_EDITOR is not set.
595

FILES

597     /etc/sudo.conf            sudo front-end configuration
598

EXAMPLES

600     The following examples assume a properly configured security policy.
601
602     To get a file listing of an unreadable directory:
603
604         $ sudo ls /usr/local/protected
605
606     To list the home directory of user yaz on a machine where the file system
607     holding ~yaz is not exported as root:
608
609         $ sudo -u yaz ls ~yaz
610
611     To edit the index.html file as user www:
612
613         $ sudoedit -u www ~www/htdocs/index.html
614
615     To view system logs only accessible to root and users in the adm group:
616
617         $ sudo -g adm more /var/log/syslog
618
619     To run an editor as jim with a different primary group:
620
621         $ sudoedit -u jim -g audio ~jim/sound.txt
622
623     To shut down a machine:
624
625         $ sudo shutdown -r +15 "quick reboot"
626
627     To make a usage listing of the directories in the /home partition.  The
628     commands are run in a sub-shell to allow the ‘cd’ command and file redi‐
629     rection to work.
630
631         $ sudo sh -c "cd /home ; du -s * | sort -rn > USAGE"
632

DIAGNOSTICS

634     Error messages produced by sudo include:
635
636     editing files in a writable directory is not permitted
637           By default, sudoedit does not permit editing a file when any of the
638           parent directories are writable by the invoking user.  This avoids
639           a race condition that could allow the user to overwrite an arbi‐
640           trary file.  See the sudoedit_checkdir option in sudoers(5) for
641           more information.
642
643     editing symbolic links is not permitted
644           By default, sudoedit does not follow symbolic links when opening
645           files.  See the sudoedit_follow option in sudoers(5) for more in‐
646           formation.
647
648     effective uid is not 0, is sudo installed setuid root?
649           sudo was not run with root privileges.  The sudo binary must be
650           owned by the root user and have the set-user-ID bit set.  Also, it
651           must not be located on a file system mounted with the ‘nosuid’ op‐
652           tion or on an NFS file system that maps uid 0 to an unprivileged
653           uid.
654
655     effective uid is not 0, is sudo on a file system with the 'nosuid' option
656           set or an NFS file system without root privileges?
657           sudo was not run with root privileges.  The sudo binary has the
658           proper owner and permissions but it still did not run with root
659           privileges.  The most common reason for this is that the file sys‐
660           tem the sudo binary is located on is mounted with the ‘nosuid’ op‐
661           tion or it is an NFS file system that maps uid 0 to an unprivileged
662           uid.
663
664     fatal error, unable to load plugins
665           An error occurred while loading or initializing the plugins speci‐
666           fied in sudo.conf(5).
667
668     invalid environment variable name
669           One or more environment variable names specified via the -E option
670           contained an equal sign (‘=’).  The arguments to the -E option
671           should be environment variable names without an associated value.
672
673     no password was provided
674           When sudo tried to read the password, it did not receive any char‐
675           acters.  This may happen if no terminal is available (or the -S op‐
676           tion is specified) and the standard input has been redirected from
677           /dev/null.
678
679     a terminal is required to read the password
680           sudo needs to read the password but there is no mechanism available
681           for it to do so.  A terminal is not present to read the password
682           from, sudo has not been configured to read from the standard input,
683           the -S option was not used, and no askpass helper has been speci‐
684           fied either via the sudo.conf(5) file or the SUDO_ASKPASS environ‐
685           ment variable.
686
687     no writable temporary directory found
688           sudoedit was unable to find a usable temporary directory in which
689           to store its intermediate files.
690
691     The “no new privileges” flag is set, which prevents sudo from running as
692           root.
693           sudo was run by a process that has the Linux “no new privileges”
694           flag is set.  This causes the set-user-ID bit to be ignored when
695           running an executable, which will prevent sudo from functioning.
696           The most likely cause for this is running sudo within a container
697           that sets this flag.  Check the documentation to see if it is pos‐
698           sible to configure the container such that the flag is not set.
699
700     sudo must be owned by uid 0 and have the setuid bit set
701           sudo was not run with root privileges.  The sudo binary does not
702           have the correct owner or permissions.  It must be owned by the
703           root user and have the set-user-ID bit set.
704
705     sudoedit is not supported on this platform
706           It is only possible to run sudoedit on systems that support setting
707           the effective user-ID.
708
709     timed out reading password
710           The user did not enter a password before the password timeout (5
711           minutes by default) expired.
712
713     you do not exist in the passwd database
714           Your user-ID does not appear in the system passwd database.
715
716     you may not specify environment variables in edit mode
717           It is only possible to specify environment variables when running a
718           command.  When editing a file, the editor is run with the user's
719           environment unmodified.
720

SEE ALSO

722     su(1), stat(2), login_cap(3), passwd(5), sudo.conf(5), sudo_plugin(5),
723     sudoers(5), sudoers_timestamp(5), sudoreplay(8), visudo(8)
724

HISTORY

726     See the HISTORY.md file in the sudo distribution
727     (https://www.sudo.ws/about/history/) for a brief history of sudo.
728

AUTHORS

730     Many people have worked on sudo over the years; this version consists of
731     code written primarily by:
732
733           Todd C. Miller
734
735     See the CONTRIBUTORS.md file in the sudo distribution
736     (https://www.sudo.ws/about/contributors/) for an exhaustive list of peo‐
737     ple who have contributed to sudo.
738

CAVEATS

740     There is no easy way to prevent a user from gaining a root shell if that
741     user is allowed to run arbitrary commands via sudo.  Also, many programs
742     (such as editors) allow the user to run commands via shell escapes, thus
743     avoiding sudo's checks.  However, on most systems it is possible to pre‐
744     vent shell escapes with the sudoers(5) plugin's noexec functionality.
745
746     It is not meaningful to run the ‘cd’ command directly via sudo, e.g.,
747
748         $ sudo cd /usr/local/protected
749
750     since when the command exits the parent process (your shell) will still
751     be the same.  The -D option can be used to run a command in a specific
752     directory.
753
754     Running shell scripts via sudo can expose the same kernel bugs that make
755     set-user-ID shell scripts unsafe on some operating systems (if your OS
756     has a /dev/fd/ directory, set-user-ID shell scripts are generally safe).
757

BUGS

759     If you believe you have found a bug in sudo, you can submit a bug report
760     at https://bugzilla.sudo.ws/
761

SUPPORT

763     Limited free support is available via the sudo-users mailing list, see
764     https://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search
765     the archives.
766

DISCLAIMER

768     sudo is provided “AS IS” and any express or implied warranties, includ‐
769     ing, but not limited to, the implied warranties of merchantability and
770     fitness for a particular purpose are disclaimed.  See the LICENSE.md file
771     distributed with sudo or https://www.sudo.ws/about/license/ for complete
772     details.
773
774Sudo 1.9.13p2                  January 16, 2023                  Sudo 1.9.13p2
Impressum