CentOS 7, like many other Linux distributions, uses cron for scheduling tasks. The crontab -e
command is commonly used for editing the cron table. The default editor for this command is typically Vim, but not all users feel comfortable with it. In this article, we'll demonstrate how to change the default editor for the crontab -e
command to Nano, which is more user-friendly for many users.
Prerequisites
Before changing the default editor, it's important to ensure that you have Nano editor installed on CentOS 7. You can verify this using the command:
which nano
If the editor is installed, this command will return the path to the application. If it's not installed, you can install it using YUM:
sudo yum install nano -y
Changing the Default Editor
There are two main methods to change the default editor for crontab -e
on CentOS 7:
1. Temporary Change of Default Editor
For a temporary change of editor, you can use the EDITOR
or VISUAL
environment variables before running the crontab -e
command. This method will change the default editor only for the current terminal session.
export EDITOR=nano
or
export VISUAL=nano
After setting this variable, you can open crontab
, and you should be redirected to the Nano editor.
2. Permanent Change of Default Editor
If you want to permanently change the default editor for all future terminal sessions, you should add the above export command to the .bashrc
or .bash_profile
file in your home directory.
Open the .bashrc
or .bash_profile
file in an editor:
nano ~/.bashrc
and add the following line to the end of the file:
export EDITOR=nano
Save and close the file. To apply the changes, either reload the configuration file using the command source ~/.bashrc
, or simply restart the terminal.
After completing these steps, Nano will be set as the default editor for crontab -e
on your CentOS 7 system.
Changing the default editor for crontab -e
on CentOS 7 to Nano can simplify editing the cron table for users who prefer this editor. With the simple steps outlined in this article, you can quickly switch between editors and increase your productivity when working with cron.