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.  This mode is the de‐
429     fault for sudo versions 1.9.14 and above when using the sudoers policy.
430
431     If no pty is used, sudo calls fork(2), sets up the execution environment
432     as described above, and uses the execve(2) system call to run the command
433     in the child process.  The main sudo process waits until the command has
434     completed, then passes the command's exit status to the security policy's
435     close function, as well as the close function of any configured audit
436     plugins, and exits.  As a special case, if the policy plugin does not de‐
437     fine a close function, sudo will execute the command directly instead of
438     calling fork(2) first.  The sudoers policy plugin will only define a
439     close function when I/O logging is enabled, a pty is required, an SELinux
440     role is specified, the command has an associated timeout, or the
441     pam_session or pam_setcred options are enabled.  Both pam_session and
442     pam_setcred are enabled by default on systems using PAM.  This mode is
443     the default for sudo versions prior to 1.9.14 when using the sudoers pol‐
444     icy.
445
446     On systems that use PAM, the security policy's close function is respon‐
447     sible for closing the PAM session.  It may also log the command's exit
448     status.
449
450   Signal handling
451     When the command is run as a child of the sudo process, sudo will relay
452     signals it receives to the command.  The SIGINT and SIGQUIT signals are
453     only relayed when the command is being run in a new pty or when the sig‐
454     nal was sent by a user process, not the kernel.  This prevents the
455     command from receiving SIGINT twice each time the user enters control-C.
456     Some signals, such as SIGSTOP and SIGKILL, cannot be caught and thus will
457     not be relayed to the command.  As a general rule, SIGTSTP should be used
458     instead of SIGSTOP when you wish to suspend a command being run by sudo.
459
460     As a special case, sudo will not relay signals that were sent by the
461     command it is running.  This prevents the command from accidentally
462     killing itself.  On some systems, the reboot(8) utility sends SIGTERM to
463     all non-system processes other than itself before rebooting the system.
464     This prevents sudo from relaying the SIGTERM signal it received back to
465     reboot(8), which might then exit before the system was actually rebooted,
466     leaving it in a half-dead state similar to single user mode.  Note, how‐
467     ever, that this check only applies to the command run by sudo and not any
468     other processes that the command may create.  As a result, running a
469     script that calls reboot(8) or shutdown(8) via sudo may cause the system
470     to end up in this undefined state unless the reboot(8) or shutdown(8) are
471     run using the exec() family of functions instead of system() (which in‐
472     terposes a shell between the command and the calling process).
473
474   Plugins
475     Plugins may be specified via Plugin directives in the sudo.conf(5) file.
476     They may be loaded as dynamic shared objects (on systems that support
477     them), or compiled directly into the sudo binary.  If no sudo.conf(5)
478     file is present, or if it doesn't contain any Plugin lines, sudo will use
479     sudoers(5) for the policy, auditing, and I/O logging plugins.  See the
480     sudo.conf(5) manual for details of the /etc/sudo.conf file and the
481     sudo_plugin(5) manual for more information about the sudo plugin archi‐
482     tecture.
483

EXIT VALUE

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

SECURITY NOTES

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

ENVIRONMENT

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

FILES

600     /etc/sudo.conf            sudo front-end configuration
601

EXAMPLES

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

DIAGNOSTICS

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

SEE ALSO

725     su(1), stat(2), login_cap(3), passwd(5), sudo.conf(5), sudo_plugin(5),
726     sudoers(5), sudoers_timestamp(5), sudoreplay(8), visudo(8)
727

HISTORY

729     See the HISTORY.md file in the sudo distribution
730     (https://www.sudo.ws/about/history/) for a brief history of sudo.
731

AUTHORS

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

CAVEATS

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

BUGS

762     If you believe you have found a bug in sudo, you can submit a bug report
763     at https://bugzilla.sudo.ws/
764

SUPPORT

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

DISCLAIMER

771     sudo is provided “AS IS” and any express or implied warranties, includ‐
772     ing, but not limited to, the implied warranties of merchantability and
773     fitness for a particular purpose are disclaimed.  See the LICENSE.md file
774     distributed with sudo or https://www.sudo.ws/about/license/ for complete
775     details.
776
777Sudo 1.9.14p3                    June 18, 2023                   Sudo 1.9.14p3
Impressum