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 There is a hard-coded list of one or more editors that visudo will use
17 set at compile-time that may be overridden via the editor sudoers Default
18 variable. This list defaults to /usr/local/bin/vi. Normally, visudo
19 does not honor the VISUAL or EDITOR environment variables unless they
20 contain an editor in the aforementioned editors list. However, if visudo
21 is configured with the --with-env-editor option or the env_editor Default
22 variable is set in sudoers, visudo will use any the editor defines by
23 VISUAL or EDITOR. Note that this can be a security hole since it allows
24 the user to execute any program they wish simply by setting VISUAL or
25 EDITOR.
26
27 visudo parses the sudoers file after the edit and will not save the
28 changes if there is a syntax error. Upon finding an error, visudo will
29 print a message stating the line number(s) where the error occurred and
30 the user will receive the “What now?” prompt. At this point the user may
31 enter ‘e’ to re-edit the sudoers file, ‘x’ to exit without saving the
32 changes, or ‘Q’ to quit and save changes. The ‘Q’ option should be used
33 with extreme care because if visudo believes there to be a parse error,
34 so will sudo and no one will be able to sudo again until the error is
35 fixed. If ‘e’ is typed to edit the sudoers file after a parse error has
36 been detected, the cursor will be placed on the line where the error
37 occurred (if the editor supports this feature).
38
39 The options are as follows:
40
41 -c Enable check-only mode. The existing sudoers file will be
42 checked for syntax errors, owner and mode. A message will be
43 printed to the standard output describing the status of
44 sudoers unless the -q option was specified. If the check
45 completes successfully, visudo will exit with a value of 0.
46 If an error is encountered, visudo will exit with a value of
47 1.
48
49 -f sudoers Specify and alternate sudoers file location. With this
50 option visudo will edit (or check) the sudoers file of your
51 choice, instead of the default, /etc/sudoers. The lock file
52 used is the specified sudoers file with “.tmp” appended to
53 it. In check-only mode only, the argument to -f may be ‘-’,
54 indicating that sudoers will be read from the standard input.
55
56 -h The -h (help) option causes visudo to print a short help mes‐
57 sage to the standard output and exit.
58
59 -q Enable quiet mode. In this mode details about syntax errors
60 are not printed. This option is only useful when combined
61 with the -c option.
62
63 -s Enable strict checking of the sudoers file. If an alias is
64 used before it is defined, visudo will consider this a parse
65 error. Note that it is not possible to differentiate between
66 an alias and a host name or user name that consists solely of
67 uppercase letters, digits, and the underscore (‘_’) charac‐
68 ter.
69
70 -V The -V (version) option causes visudo to print its version
71 number and exit.
72
74 The following environment variables may be consulted depending on the
75 value of the editor and env_editor sudoers settings:
76
77 VISUAL Invoked by visudo as the editor to use
78
79 EDITOR Used by visudo if VISUAL is not set
80
82 /etc/sudoers List of who can run what
83
84 /etc/sudoers.tmp Lock file for visudo
85
87 sudoers file busy, try again later.
88 Someone else is currently editing the sudoers file.
89
90 /etc/sudoers.tmp: Permission denied
91 You didn't run visudo as root.
92
93 Can't find you in the passwd database
94 Your user ID does not appear in the system passwd file.
95
96 Warning: {User,Runas,Host,Cmnd}_Alias referenced but not defined
97 Either you are trying to use an undeclared
98 {User,Runas,Host,Cmnd}_Alias or you have a user or host name listed
99 that consists solely of uppercase letters, digits, and the under‐
100 score (‘_’) character. In the latter case, you can ignore the
101 warnings (sudo will not complain). In -s (strict) mode these are
102 errors, not warnings.
103
104 Warning: unused {User,Runas,Host,Cmnd}_Alias
105 The specified {User,Runas,Host,Cmnd}_Alias was defined but never
106 used. You may wish to comment out or remove the unused alias. In
107 -s (strict) mode this is an error, not a warning.
108
109 Warning: cycle in {User,Runas,Host,Cmnd}_Alias
110 The specified {User,Runas,Host,Cmnd}_Alias includes a reference to
111 itself, either directly or through an alias it includes. This is
112 only a warning by default as sudo will ignore cycles when parsing
113 the sudoers file.
114
116 vi(1), sudoers(5), sudo(8), vipw(8)
117
119 Many people have worked on sudo over the years; this version consists of
120 code written primarily by:
121
122 Todd C. Miller
123
124 See the CONTRIBUTORS file in the sudo distribution
125 (http://www.sudo.ws/sudo/contributors.html) for an exhaustive list of
126 people who have contributed to sudo.
127
129 There is no easy way to prevent a user from gaining a root shell if the
130 editor used by visudo allows shell escapes.
131
133 If you feel you have found a bug in visudo, please submit a bug report at
134 http://www.sudo.ws/sudo/bugs/
135
137 Limited free support is available via the sudo-users mailing list, see
138 http://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search the
139 archives.
140
142 visudo is provided “AS IS” and any express or implied warranties, includ‐
143 ing, but not limited to, the implied warranties of merchantability and
144 fitness for a particular purpose are disclaimed. See the LICENSE file
145 distributed with sudo or http://www.sudo.ws/sudo/license.html for com‐
146 plete details.
147
148Sudo 1.8.6p3 July 12, 2012 Sudo 1.8.6p3