How to Change the Default Editor for crontab -e from Vim to Nano | 12.12.2023
To change the default editor for crontab -e
from Vim to Nano, you need to set the EDITOR
environment variable to nano. There are a few ways to do this:
export EDITOR=nano
This command sets Nano as the editor for the duration of the terminal session. Once you close the terminal, the setting will revert.
To make Nano the default editor permanently, you need to add the setting to your shell's configuration file.
export EDITOR=nano
to your .bashrc
or .bash_profile
file in your home directory.source ~/.bashrc
.This change will make Nano the default editor for all future terminal sessions. After applying one of these methods, Nano will be used as the default editor when you run crontab -e
.
Some Linux distributions (especially Debian-based ones) include a utility called select-editor
.
select-editor
in your terminal.On Debian-based systems, you can use update-alternatives
to set the default editor for all users.
sudo update-alternatives --config editor
in the terminal.Similar to EDITOR
, the VISUAL
environment variable can also be set to your preferred editor.
.bashrc
or .bash_profile
, add export VISUAL=nano
.VISUAL
over EDITOR
.Some cron implementations allow setting the default editor directly in the cron configuration file. This is less common and depends on the specific cron daemon you are using.