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. 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 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 lock file used is the specified sudoers file with “.tmp” appended to
94 it. In check-only mode only, ‘-’ may be used to indicate that sudoers
95 will be read from the standard input. Because the policy is evaluated in
96 its entirety, it is not sufficient to check an individual sudoers include
97 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 Lock file for 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.tmp: 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.8.27 December 24, 2018 Sudo 1.8.27