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

NAME

4     visudo — edit the sudoers file
5

SYNOPSIS

7     visudo [-chqsV] [-f sudoers]
8

DESCRIPTION

10     visudo edits the sudoers file in a safe fashion, analogous to vipw(8).
11     visudo locks the sudoers file against multiple simultaneous edits, pro‐
12     vides basic sanity checks, and checks for parse errors.  If the sudoers
13     file is currently being edited you will receive a message to try again
14     later.
15
16     visudo parses the sudoers file after editing and will not save the
17     changes if there is a syntax error.  Upon finding an error, visudo will
18     print a message stating the line number(s) where the error occurred and
19     the user will receive the “What now?” prompt.  At this point the user may
20     enter ‘e’ to re-edit the sudoers file, ‘x’ to exit without saving the
21     changes, or ‘Q’ to quit and save changes.  The ‘Q’ option should be used
22     with extreme caution because if visudo believes there to be a parse
23     error, so will sudo and no one will be able to run sudo again until the
24     error is fixed.  If ‘e’ is typed to edit the sudoers file after a parse
25     error has been detected, the cursor will be placed on the line where the
26     error occurred (if the editor supports this feature).
27
28     There are two sudoers settings that determine which editor visudo will
29     run.
30
31     editor    A colon (‘:’) separated list of editors allowed to be used with
32               visudo.  visudo will choose the editor that matches the user's
33               SUDO_EDITOR, VISUAL or EDITOR environment variable if possible,
34               or the first editor in the list that exists and is executable.
35               Note that the SUDO_EDITOR, VISUAL and EDITOR environment vari‐
36               ables are not preserved by default when the env_reset sudoers
37               option is enabled.  The default editor path is /bin/vi which
38               can be set at compile time via the --with-editor configure
39               option.
40
41     env_editor
42               If set, visudo will use the value of the SUDO_EDITOR, VISUAL or
43               EDITOR environment variables before falling back on the default
44               editor list.  Note that this may create a security hole as it
45               allows the user to run any arbitrary command as root without
46               logging.  A safer alternative is to place a colon-separated
47               list of editors in the editor variable.  visudo will then only
48               use SUDO_EDITOR, VISUAL or EDITOR if they match a value speci‐
49               fied in editor.  If the env_reset flag is enabled, the
50               SUDO_EDITOR, VISUAL and/or EDITOR environment variables must be
51               present in the env_keep list for the env_editor flag to func‐
52               tion when visudo is invoked via sudo.  The default value is on,
53               which can be set at compile time via the --with-env-editor con‐
54               figure option.
55
56     The options are as follows:
57
58     -c, --check
59                 Enable check-only mode.  The existing sudoers file (and any
60                 other files it includes) will be checked for syntax errors.
61                 If the -f option has not been specified, visudo will also
62                 check the sudoers file owner and mode.  A message will be
63                 printed to the standard output describing the status of
64                 sudoers unless the -q option was specified.  If the check
65                 completes successfully, visudo will exit with a value of 0.
66                 If an error is encountered, visudo will exit with a value of
67                 1.
68
69     -f sudoers, --file=sudoers
70                 Specify an alternate sudoers file location.  With this
71                 option, visudo will edit (or check) the sudoers file of your
72                 choice, instead of the default, /etc/sudoers.  The lock file
73                 used is the specified sudoers file with “.tmp” appended to
74                 it.  In check-only mode only, the argument to -f may be ‘-’,
75                 indicating that sudoers will be read from the standard input.
76                 Because the policy is evaluated in its entirety, it is not
77                 sufficient to check an individual sudoers include file for
78                 syntax errors.
79
80     -h, --help  Display a short help message to the standard output and exit.
81
82     -q, --quiet
83                 Enable quiet mode.  In this mode details about syntax errors
84                 are not printed.  This option is only useful when combined
85                 with the -c option.
86
87     -s, --strict
88                 Enable strict checking of the sudoers file.  If an alias is
89                 referenced but not actually defined or if there is a cycle in
90                 an alias, visudo will consider this a parse error.  Note that
91                 it is not possible to differentiate between an alias and a
92                 host name or user name that consists solely of uppercase let‐
93                 ters, digits, and the underscore (‘_’) character.
94
95     -V, --version
96                 Print the visudo and sudoers grammar versions and exit.
97
98   Debugging and sudoers plugin arguments
99     visudo versions 1.8.4 and higher support a flexible debugging framework
100     that is configured via Debug lines in the sudo.conf(5) file.
101
102     Starting with sudo 1.8.12, visudo will also parse the arguments to the
103     sudoers plugin to override the default sudoers path name, UID, GID and
104     file mode.  These arguments, if present, should be listed after the path
105     to the plugin (i.e. after sudoers.so).  Multiple arguments may be speci‐
106     fied, separated by white space.  For example:
107
108           Plugin sudoers_policy sudoers.so sudoers_mode=0400
109
110     The following arguments are supported:
111
112     sudoers_file=pathname
113               The sudoers_file argument can be used to override the default
114               path to the sudoers file.
115
116     sudoers_uid=uid
117               The sudoers_uid argument can be used to override the default
118               owner of the sudoers file.  It should be specified as a numeric
119               user ID.
120
121     sudoers_gid=gid
122               The sudoers_gid argument can be used to override the default
123               group of the sudoers file.  It must be specified as a numeric
124               group ID (not a group name).
125
126     sudoers_mode=mode
127               The sudoers_mode argument can be used to override the default
128               file mode for the sudoers file.  It should be specified as an
129               octal value.
130
131     For more information on configuring sudo.conf(5), please refer to its
132     manual.
133

ENVIRONMENT

135     The following environment variables may be consulted depending on the
136     value of the editor and env_editor sudoers settings:
137
138     SUDO_EDITOR      Invoked by visudo as the editor to use
139
140     VISUAL           Used by visudo if SUDO_EDITOR is not set
141
142     EDITOR           Used by visudo if neither SUDO_EDITOR nor VISUAL is set
143

FILES

145     /etc/sudo.conf            Sudo front end configuration
146
147     /etc/sudoers              List of who can run what
148
149     /etc/sudoers.tmp          Lock file for visudo
150

DIAGNOSTICS

152     In addition to reporting sudoers parse errors, visudo may produce the
153     following messages:
154
155     sudoers file busy, try again later.
156           Someone else is currently editing the sudoers file.
157
158     /etc/sudoers.tmp: Permission denied
159           You didn't run visudo as root.
160
161     you do not exist in the passwd database
162           Your user ID does not appear in the system passwd database.
163
164     Warning: {User,Runas,Host,Cmnd}_Alias referenced but not defined
165           Either you are trying to use an undeclared
166           {User,Runas,Host,Cmnd}_Alias or you have a user or host name listed
167           that consists solely of uppercase letters, digits, and the under‐
168           score (‘_’) character.  In the latter case, you can ignore the
169           warnings (sudo will not complain).  The message is prefixed with
170           the path name of the sudoers file and the line number where the
171           undefined alias was used.  In -s (strict) mode these are errors,
172           not warnings.
173
174     Warning: unused {User,Runas,Host,Cmnd}_Alias
175           The specified {User,Runas,Host,Cmnd}_Alias was defined but never
176           used.  The message is prefixed with the path name of the sudoers
177           file and the line number where the unused alias was defined.  You
178           may wish to comment out or remove the unused alias.
179
180     Warning: cycle in {User,Runas,Host,Cmnd}_Alias
181           The specified {User,Runas,Host,Cmnd}_Alias includes a reference to
182           itself, either directly or through an alias it includes.  The mes‐
183           sage is prefixed with the path name of the sudoers file and the
184           line number where the cycle was detected.  This is only a warning
185           unless visudo is run in -s (strict) mode as sudo will ignore cycles
186           when parsing the sudoers file.
187
188     unknown defaults entry "name"
189           The sudoers file contains a Defaults setting not recognized by
190           visudo.
191

SEE ALSO

193     vi(1), sudo.conf(5), sudoers(5), sudo(8), vipw(8)
194

AUTHORS

196     Many people have worked on sudo over the years; this version consists of
197     code written primarily by:
198
199           Todd C. Miller
200
201     See the CONTRIBUTORS file in the sudo distribution
202     (https://www.sudo.ws/contributors.html) for an exhaustive list of people
203     who have contributed to sudo.
204

CAVEATS

206     There is no easy way to prevent a user from gaining a root shell if the
207     editor used by visudo allows shell escapes.
208

BUGS

210     If you feel you have found a bug in visudo, please submit a bug report at
211     https://bugzilla.sudo.ws/
212

SUPPORT

214     Limited free support is available via the sudo-users mailing list, see
215     https://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search
216     the archives.
217

DISCLAIMER

219     visudo is provided “AS IS” and any express or implied warranties, includ‐
220     ing, but not limited to, the implied warranties of merchantability and
221     fitness for a particular purpose are disclaimed.  See the LICENSE file
222     distributed with sudo or https://www.sudo.ws/license.html for complete
223     details.
224
225Sudo 1.8.25p1                  January 26, 2018                  Sudo 1.8.25p1
Impressum