修改visudo的默认编辑器为vim

926 阅读1分钟

ubuntu22.04 默认执行visudo时候会使用nano打开/etc/sudoers文件,编辑不方便

修改为vim,执行sudo update-alternatives --config editor命令,选择vim即可

➜  ~ sudo update-alternatives --config editor
There are 6 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path                    Priority   Status
------------------------------------------------------------
* 0            /bin/nano                40        auto mode
  1            /bin/ed                 -100       manual mode
  2            /bin/nano                40        manual mode
  3            /usr/bin/code            0         manual mode
  4            /usr/bin/code-insiders   0         manual mode
  5            /usr/bin/vim.basic       30        manual mode
  6            /usr/bin/vim.tiny        15        manual mode

Press <enter> to keep the current choice[*], or type selection number: 5           
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in manual mode
➜  ~ sudo visudo
visudo: /etc/sudoers.tmp unchanged