debian修改默认编辑器

本文介绍在Debian系统中如何使用update-alternatives命令更改默认编辑器,并提供了通过命令行选择不同编辑器的详细步骤。此外还介绍了如何通过设置环境变量来临时指定编辑器。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

刚才在一台机器上打开 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了。

转载于:https://www.cnblogs.com/keithtt/p/7357995.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值