debian修改默認編輯器


剛才在一台機器上打開 crontab -e,跳出來的編輯器是nano,太難使...

在debian下是使用 update-alternatives 命令修改默認編輯器。

先查看一下使用幫助

# update-alternatives --help

Usage: update-alternatives [<option> ...] <command>

--config <name>:show alternatives for the <name> group and ask the user to select which one to use.

修改默認編輯器,選擇4 /usr/bin/vim.basic

# update-alternatives --config editor
There are 5 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/emacs23     0         manual mode
  4            /usr/bin/vim.basic   30        manual mode
  5            /usr/bin/vim.tiny    10        manual mode

Press enter to keep the current choice[*], or type selection number: 4
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in manual mode

順着提示看了一下對應的文件,都是軟鏈接,最終指向 /usr/bin/vim.basic

# ls -l /usr/bin/editor
lrwxrwxrwx 1 root root 24 Dec  8  2015 /usr/bin/editor -> /etc/alternatives/editor
# ls -l /etc/alternatives/editor
lrwxrwxrwx 1 root root 18 Aug 14 15:00 /etc/alternatives/editor -> /usr/bin/vim.basic

另外,可以通過導出變量臨時修改編輯器:

export EDITOR="/usr/bin/vim" ; crontab -e

這樣,再次打開 crontab -e,跳出來的就是vim了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM