How can I properly set sudo/visudo's editor?
Solution 1:
You are right that setting the EDITOR
variable should change the editor used for sudo
. However, there are two other variables with precedence over the EDITOR
: SUDO_EDITOR
and VISUAL
. Make sure none of them point to some other editor like nano
.
Solution 2:
There's another solution as described here:
sudo update-alternatives --config editor
But it's not so friendly on a multi-user system as it only updates a symlink in /usr/bin/
:
$ ls -l `which editor`
lrwxrwxrwx 1 root root 24 lip 4 19:37 /usr/bin/editor -> /etc/alternatives/editor
$ ls -l /etc/alternatives/editor
lrwxrwxrwx 1 root root 18 Jul 5 01:39 /etc/alternatives/editor -> /usr/bin/vim.basic
What happened to select-editor
anyway? When I run it, it creates a file:
$ ls -l .selected_editor
-rw-r--r-- 1 rld rld 75 Jul 5 01:54 .selected_editor
$ cat .selected_editor
# Generated by /usr/bin/select-editor
SELECTED_EDITOR="/usr/bin/vim.basic"
But sudo visudo
keeps using nano.
Solution 3:
In Debian 7, setting EDITOR in the environment didn't work.
To use Nano, I ended up adding the following line to /etc/sudoers
Defaults editor="/usr/bin/nano"