I tried to run the "sudo EDITOR=./sudo_editor visudo -f /etc/sudoers.d/relax_requirements" command and the error came out as: visudo: specified editor (./sudo_editor) doesn't exist
Anyone know what I should do in this situation?
You could just edit your sudo files with any editor, visudo
just does it "in a safe fashion" to guard against some errors. But you can DIY with any editor, just keep a backup copy handy and a live iso ready to fix any errors just in case.
man visudo
says:
There is a hard-coded list of one or more editors that visudo will use
set at compile-time that may be overridden via the editor sudoers Default
variable. This list defaults to /usr/local/bin/vi. Normally, visudo
does not honor the VISUAL or EDITOR environment variables unless they
contain an editor in the aforementioned editors list. However, if visudo
is configured with the --with-env-editor option or the env_editor Default
variable is set in sudoers, visudo will use any the editor defines by
VISUAL or EDITOR. Note that this can be a security hole since it allows
the user to execute any program they wish simply by setting VISUAL or
EDITOR.
So maybe your visudo
can't override it's hard-coded list of editors. You could try refering to the editor with it's complete path, instead of ./
and that might work, or try a "default" editor like vi
or nano
(find their path with which
). Or just running this worked for me (though I can't recommend vi
;-)
sudo EDITOR=vi visudo
Or
sudo EDITOR=nano visudo
Or even using a nice graphic editor like gedit
if it's installed:
sudo EDITOR=gedit visudo
On a regular Ubuntu, (or Linux Mint & others too) just running this alone should work too:
sudo visudo
Or in your specific file's case:
sudo visudo -f /etc/sudoers.d/relax_requirements
visudo
now? That's good news, your original question is answered at least, now you can accept (check-mark) the answer if it worked.
man sudoers
or man sudo
for more info. Or you can ask a new question, asking exactly what you're trying to do, that might be easier
sudo EDITOR=nano visudo -f /etc/sudoers.d/relax_requirements
" might be easier than using vi
too, but vi
and nano
should be on Ubuntu... And visudo is supposed to "lock" the files so they can't be edited by 2 different programs at the same time. You can look for other running visudo
programs with "pgrep -l visudo"
and only run one at a time (can kill others with "sudo pkill visudo
" but if it's been suspended then closing the terminal or fg
should finish it off.