1VISUDO(8) BSD System Manager's Manual VISUDO(8)
2
4 visudo — edit the sudoers file
5
7 visudo [-chqsV] [[-f] sudoers]
8
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 before installing
13 the edited file. If the sudoers file is currently being edited you will
14 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 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 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 /bin/vi which can be
39 set at compile time via the --with-editor configure 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 visudo is typically run as root so this
45 option may allow a user with visudo privileges to run arbitrary
46 commands as root without logging. An alternative is to place a
47 colon-separated list of “safe” editors int the editor variable.
48 visudo will then only use SUDO_EDITOR, VISUAL or EDITOR if they
49 match a value specified in editor. If the env_reset flag is
50 enabled, the SUDO_EDITOR, VISUAL and/or EDITOR environment
51 variables must be present in the env_keep list for the
52 env_editor flag to function when visudo is invoked via sudo.
53 The default value is on, which can be set at compile time via
54 the --with-env-editor configure 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 path to the sudoers file was not specified, visudo
62 will also check the 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, see below. As of
71 version 1.8.27, the sudoers path can be specified without
72 using the -f option.
73
74 -h, --help Display a short help message to the standard output and exit.
75
76 -q, --quiet
77 Enable quiet mode. In this mode details about syntax errors
78 are not printed. This option is only useful when combined
79 with the -c option.
80
81 -s, --strict
82 Enable strict checking of the sudoers file. If an alias is
83 referenced but not actually defined or if there is a cycle in
84 an alias, visudo will consider this a parse error. Note that
85 it is not possible to differentiate between an alias and a
86 host name or user name that consists solely of uppercase let‐
87 ters, digits, and the underscore (‘_’) character.
88
89 -V, --version
90 Print the visudo and sudoers grammar versions and exit.
91
92 A sudoers file may be specified instead of the default, /etc/sudoers.
93 The temporary file used is the specified sudoers file with “.tmp”
94 appended to it. In check-only mode only, ‘-’ may be used to indicate
95 that sudoers will be read from the standard input. Because the policy is
96 evaluated in its entirety, it is not sufficient to check an individual
97 sudoers include file for syntax errors.
98
99 Debugging and sudoers plugin arguments
100 visudo versions 1.8.4 and higher support a flexible debugging framework
101 that is configured via Debug lines in the sudo.conf(5) file.
102
103 Starting with sudo 1.8.12, visudo will also parse the arguments to the
104 sudoers plugin to override the default sudoers path name, UID, GID and
105 file mode. These arguments, if present, should be listed after the path
106 to the plugin (i.e., after sudoers.so). Multiple arguments may be speci‐
107 fied, separated by white space. For example:
108
109 Plugin sudoers_policy sudoers.so sudoers_mode=0400
110
111 The following arguments are supported:
112
113 sudoers_file=pathname
114 The sudoers_file argument can be used to override the default
115 path to the sudoers file.
116
117 sudoers_uid=uid
118 The sudoers_uid argument can be used to override the default
119 owner of the sudoers file. It should be specified as a numeric
120 user-ID.
121
122 sudoers_gid=gid
123 The sudoers_gid argument can be used to override the default
124 group of the sudoers file. It must be specified as a numeric
125 group-ID (not a group name).
126
127 sudoers_mode=mode
128 The sudoers_mode argument can be used to override the default
129 file mode for the sudoers file. It should be specified as an
130 octal value.
131
132 For more information on configuring sudo.conf(5), please refer to its
133 manual.
134
136 The following environment variables may be consulted depending on the
137 value of the editor and env_editor sudoers settings:
138
139 SUDO_EDITOR Invoked by visudo as the editor to use
140
141 VISUAL Used by visudo if SUDO_EDITOR is not set
142
143 EDITOR Used by visudo if neither SUDO_EDITOR nor VISUAL is set
144
146 /etc/sudo.conf Sudo front end configuration
147
148 /etc/sudoers List of who can run what
149
150 /etc/sudoers.tmp Default temporary file used by visudo
151
153 In addition to reporting sudoers parse errors, visudo may produce the
154 following messages:
155
156 sudoers file busy, try again later.
157 Someone else is currently editing the sudoers file.
158
159 /etc/sudoers: Permission denied
160 You didn't run visudo as root.
161
162 you do not exist in the passwd database
163 Your user-ID does not appear in the system passwd database.
164
165 Warning: {User,Runas,Host,Cmnd}_Alias referenced but not defined
166 Either you are trying to use an undeclared
167 {User,Runas,Host,Cmnd}_Alias or you have a user or host name listed
168 that consists solely of uppercase letters, digits, and the under‐
169 score (‘_’) character. In the latter case, you can ignore the
170 warnings (sudo will not complain). The message is prefixed with
171 the path name of the sudoers file and the line number where the
172 undefined alias was used. In -s (strict) mode these are errors,
173 not warnings.
174
175 Warning: unused {User,Runas,Host,Cmnd}_Alias
176 The specified {User,Runas,Host,Cmnd}_Alias was defined but never
177 used. The message is prefixed with the path name of the sudoers
178 file and the line number where the unused alias was defined. You
179 may wish to comment out or remove the unused alias.
180
181 Warning: cycle in {User,Runas,Host,Cmnd}_Alias
182 The specified {User,Runas,Host,Cmnd}_Alias includes a reference to
183 itself, either directly or through an alias it includes. The mes‐
184 sage is prefixed with the path name of the sudoers file and the
185 line number where the cycle was detected. This is only a warning
186 unless visudo is run in -s (strict) mode as sudo will ignore cycles
187 when parsing the sudoers file.
188
189 unknown defaults entry "name"
190 The sudoers file contains a Defaults setting not recognized by
191 visudo.
192
194 vi(1), sudo.conf(5), sudoers(5), sudo(8), vipw(8)
195
197 Many people have worked on sudo over the years; this version consists of
198 code written primarily by:
199
200 Todd C. Miller
201
202 See the CONTRIBUTORS file in the sudo distribution
203 (https://www.sudo.ws/contributors.html) for an exhaustive list of people
204 who have contributed to sudo.
205
207 There is no easy way to prevent a user from gaining a root shell if the
208 editor used by visudo allows shell escapes.
209
211 If you feel you have found a bug in visudo, please submit a bug report at
212 https://bugzilla.sudo.ws/
213
215 Limited free support is available via the sudo-users mailing list, see
216 https://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search
217 the archives.
218
220 visudo is provided “AS IS” and any express or implied warranties, includ‐
221 ing, but not limited to, the implied warranties of merchantability and
222 fitness for a particular purpose are disclaimed. See the LICENSE file
223 distributed with sudo or https://www.sudo.ws/license.html for complete
224 details.
225
226Sudo 1.9.0b4 October 20, 2019 Sudo 1.9.0b4