This guide intends to teach you to Open Crontab in Nano Editor in Linux Terminal. As you may know, the default crontab editor is Vi editor. If you want to change its default, you can follow the rest of the article.
Crontab which stands for Cron table, is a list of commands that you can use to run them on a schedule. In simple words, it is a job scheduler. To get more information about Crontab, you can visit this guide on Cron in Linux.
When you want to open the Crontab file, it opens with the Vi editor. But if you are interested in using the Nano editor instead, you can make a simple change to the bash profile and start using it.
Steps To Open Crontab in Nano Editor on Linux Terminal
To complete the guide steps, you must have SSH access to your Linux server as a root or non-root user with sudo privileges. For this purpose, you can visit the Orcacore website and search for the Linux server’s initial guides.
When you start crontab for the first time, you’ll see a prompt asking you to choose the default text editor for editing crontab files. But if you want to change the editor later on, you can follow the steps below.
Step 1 – How to open crontab with a specific editor?
At this point, you can use the select-editor command to choose your default editor in your Linux distribution. To see how it works, run the command below in your Linux terminal:
In your output, you will see:
Output Select an editor. 1. /bin/nano <---- easiest 2. /usr/bin/vim.basic 3. /usr/bin/vim.tiny 4. /bin/ed Choose 1-4 :
From there, you can choose your desired editor, and the next time you run the crontab -e command it will open in your chosen editor.
Step 2 – How to edit crontab in nano editor?
Another way that you can change your default editor is to use the environment variables. If you want to open crontab with nano, you need to make sure that you have installed it on your server. To see how you can install it on your Linux server, you can visit this guide on Work with Nano editor.
Then, you need to open your bashrc profile with the following command:
Add the following line at the end of the file:
When you are done, save and close the file.
Next, reload the bashrc profile to apply the changes:
At this point, when you open your crontab, it will open in nano:
Note: Any time you want to change it to the Vi editor, you can edit the file and use vim:
At this point, you have learned to open crontab in a specific text editor like nano editor in a Linux command line terminal. Hope you enjoy it. If you need any help or have an idea, please comment for us.