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, per‐
12     forms basic validity checks, and checks for syntax errors before in‐
13     stalling the edited file.  If the sudoers file is currently being edited
14     you will receive a message to try again 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 syntax er‐
23     ror, so will sudo and no one will be able to run sudo again until the er‐
24     ror is fixed.  If ‘e’ is typed to edit the sudoers file after a syntax
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 sudo does not preserve the SUDO_EDITOR, VISUAL or
36               EDITOR environment variables unless they are present in the
37               env_keep list or the env_reset option is disabled in the
38               sudoers file.  The default editor path is
39               /usr/bin/nano:/usr/bin/vim:/usr/bin/vi which can be set at com‐
40               pile time via the --with-editor configure option.
41
42     env_editor
43               If set, visudo will use the value of the SUDO_EDITOR, VISUAL or
44               EDITOR environment variables before falling back on the default
45               editor list.  Note that visudo is typically run as root so this
46               option may allow a user with visudo privileges to run arbitrary
47               commands as root without logging.  An alternative is to place a
48               colon-separated list of “safe” editors int the editor variable.
49               visudo will then only use SUDO_EDITOR, VISUAL or EDITOR if they
50               match a value specified in editor.  If the env_reset flag is
51               enabled, the SUDO_EDITOR, VISUAL and/or EDITOR environment
52               variables must be present in the env_keep list for the
53               env_editor flag to function when visudo is invoked via sudo.
54               The default value is on, which can be set at compile time via
55               the --with-env-editor configure option.
56
57     The options are as follows:
58
59     -c, --check
60                 Enable check-only mode.  The existing sudoers file (and any
61                 other files it includes) will be checked for syntax errors.
62                 If the path to the sudoers file was not specified, visudo
63                 will also check the file owner and mode.  A message will be
64                 printed to the standard output describing the status of
65                 sudoers unless the -q option was specified.  If the check
66                 completes successfully, visudo will exit with a value of 0.
67                 If an error is encountered, visudo will exit with a value of
68                 1.
69
70     -f sudoers, --file=sudoers
71                 Specify an alternate sudoers file location, see below.  As of
72                 version 1.8.27, the sudoers path can be specified without us‐
73                 ing the -f option.
74
75     -h, --help  Display a short help message to the standard output and exit.
76
77     -q, --quiet
78                 Enable quiet mode.  In this mode details about syntax errors
79                 are not printed.  This option is only useful when combined
80                 with the -c option.
81
82     -s, --strict
83                 Enable strict checking of the sudoers file.  If an alias is
84                 referenced but not actually defined or if there is a cycle in
85                 an alias, visudo will consider this a syntax error.  Note
86                 that it is not possible to differentiate between an alias and
87                 a host name or user name that consists solely of uppercase
88                 letters, digits, and the underscore (‘_’) character.
89
90     -V, --version
91                 Print the visudo and sudoers grammar versions and exit.
92
93     A sudoers file may be specified instead of the default, /etc/sudoers.
94     The temporary file used is the specified sudoers file with “.tmp” ap‐
95     pended to it.  In check-only mode only, ‘-’ may be used to indicate that
96     sudoers will be read from the standard input.  Because the policy is
97     evaluated in its entirety, it is not sufficient to check an individual
98     sudoers include file for syntax errors.
99
100   Debugging and sudoers plugin arguments
101     visudo versions 1.8.4 and higher support a flexible debugging framework
102     that is configured via Debug lines in the sudo.conf(5) file.
103
104     Starting with sudo 1.8.12, visudo will also parse the arguments to the
105     sudoers plugin to override the default sudoers path name, UID, GID and
106     file mode.  These arguments, if present, should be listed after the path
107     to the plugin (i.e., after sudoers.so).  Multiple arguments may be speci‐
108     fied, separated by white space.  For example:
109
110           Plugin sudoers_policy sudoers.so sudoers_mode=0400
111
112     The following arguments are supported:
113
114     sudoers_file=pathname
115               The sudoers_file argument can be used to override the default
116               path to the sudoers file.
117
118     sudoers_uid=uid
119               The sudoers_uid argument can be used to override the default
120               owner of the sudoers file.  It should be specified as a numeric
121               user-ID.
122
123     sudoers_gid=gid
124               The sudoers_gid argument can be used to override the default
125               group of the sudoers file.  It must be specified as a numeric
126               group-ID (not a group name).
127
128     sudoers_mode=mode
129               The sudoers_mode argument can be used to override the default
130               file mode for the sudoers file.  It should be specified as an
131               octal value.
132
133     For more information on configuring sudo.conf(5), please refer to its
134     manual.
135

ENVIRONMENT

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

FILES

147     /etc/sudo.conf            Sudo front end configuration
148
149     /etc/sudoers              List of who can run what
150
151     /etc/sudoers.tmp          Default temporary file used by visudo
152

DIAGNOSTICS

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

SEE ALSO

195     vi(1), sudo.conf(5), sudoers(5), sudo(8), vipw(8)
196

AUTHORS

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

CAVEATS

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

BUGS

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

SUPPORT

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

DISCLAIMER

221     visudo is provided “AS IS” and any express or implied warranties, includ‐
222     ing, but not limited to, the implied warranties of merchantability and
223     fitness for a particular purpose are disclaimed.  See the LICENSE file
224     distributed with sudo or https://www.sudo.ws/license.html for complete
225     details.
226
227Sudo 1.9.8p2                    August 27, 2020                   Sudo 1.9.8p2
Impressum