Set Nano as Default Editor for crontab on Linux and Ionos Webhosting Server

If you work over SSH on a web or shared hosting server, you may run into this common situation: you type crontab -e and the system opens Vim or Vi instead of Nano. If you prefer Nano because it is simpler and has no modes, this can slow you down. This guide shows how to switch the default editor to Nano both temporarily and permanently on typical Linux systems and on Ionos (formerly 1&1) shared hosting. You will also find tips, gotchas and a short reference for Vim.

What is Nano

Nano is a lightweight, user friendly terminal editor. It uses straightforward shortcuts like Ctrl+O to save and Ctrl+X to exit. For quick edits of config files or cron jobs it is often the fastest choice.

What is Vim

Vim (Vi Improved) is a powerful editor with a modal workflow. That power comes with a learning curve. These basics help you exit and save if you land in Vim by accident:

ActionKeysDescription
Switch to command modeEscLeave insert mode
Save file:w + EnterWrite file to disk
Save and quit:wq + EnterWrite and exit
Quit without saving:q! + EnterExit and discard changes
Quit if unchanged:q + EnterExit if no edits were made

If you prefer Nano, changing the default editor is the easiest fix.

Temporarily change the editor to Nano

Use this when you only want Nano for a single command or a single session.

export EDITOR="/usr/bin/nano"
export VISUAL="$EDITOR"
crontab -e

Short one-liner for a single run:

EDITOR=nano crontab -e

crontab -e checks VISUAL first, then EDITOR. If set, Nano opens just for that call.

Permanently set Nano as the default editor

Set environment variables in a shell startup file so every new SSH login picks Nano automatically.

Step 1 – Create or edit your profile file

Open your profile file in your home directory:

nano ~/.profile

If you use Bash and .profile is not read, try ~/.bash_profile. For Zsh users, prefer ~/.zprofile.

Step 2 – Add the variables

Append these lines at the end:

export EDITOR="/usr/bin/nano"
export VISUAL="$EDITOR"

If Nano lives elsewhere on your system, adjust the path. Check with which nano.

Step 3 – Start a new session

Log out and back in or open a new SSH session. Verify:

echo $EDITOR
echo $VISUAL

The output should be /usr/bin/nano or nano. Now crontab -e should open Nano.

Systemwide setting (servers you administer)

If you have root, you can set the default editor for all users:

sudo nano /etc/profile.d/nano.sh

Add:

export VISUAL="nano"
export EDITOR="nano"

This applies to new logins for every user.

Tip for Debian and Ubuntu servers you manage yourself: you can also run sudo update-alternatives --config editor to pick Nano as the system default editor. This is not available on most shared hosting plans.

Ionos 1&1 shared hosting – what works reliably

On Ionos shared hosting with SSH, .profile in your home directory is the most dependable place to set the variables.

  1. Log in via SSH to your hosting account.
  2. Go to your home directory: cd ~.
  3. Edit your profile file: nano ~/.profile.
  4. Add:
    • export EDITOR="/usr/bin/nano"
    • export VISUAL="$EDITOR"
  5. Save with Ctrl+O, Enter and exit with Ctrl+X.
  6. Log out and back in. Run crontab -e to confirm that Nano opens.

Notes for shared hosting:

  • Some providers do not read .bashrc or .bash_profile for login shells. .profile is usually read.
  • On accounts with restricted shells, shell startup behavior may differ. If nothing changes, check which shell you are in with echo $SHELL.

Additional tips and useful details

  • Identify your shell – run echo $SHELL or ps -p $$ -o comm=. This tells you which startup file is likely used.
  • Root vs user crontabsudo crontab -e uses root’s environment. Your user’s EDITOR and VISUAL will not apply unless you also set them for root. You can force it once with sudo EDITOR=nano crontab -e. For visudo, use sudo EDITOR=nano visudo.
  • Backup before edits – keep a copy of your profile file: cp ~/.profile ~/.profile.bkp.
  • Effects beyond crontab – many tools respect EDITOR or VISUAL. Examples include git commit, vipw, visudo and various maintenance scripts that open an editor.
  • Cron job environment – cron runs with a minimal environment. Setting EDITOR helps for editing with crontab -e, but variables you want inside cron jobs should be set explicitly in the crontab or sourced from a script.
  • Check Nano installation – verify with which nano and nano -V. If Nano is missing, install it on servers you manage. On shared hosting you cannot install packages, so rely on what the provider offers.

FAQ

Why do I still get Vim after editing .profile
Common reasons: you did not start a new login shell, the shell reads a different file, or you edited the file for the wrong user. Also check the path to Nano and confirm the variables with echo $EDITOR and echo $VISUAL.

Can I make the change without touching profile files
Yes – prefix a single command with EDITOR=nano or export the variables for the current session only.

Does this affect Git and other tools
Yes – most command line tools that open an editor will prefer VISUAL and EDITOR. After this change they will open Nano.

What about sudo
sudo usually runs with a clean environment. For one-off edits you can do sudo EDITOR=nano command. If you want persistent behavior for root, set the variables in root’s environment or use update-alternatives on servers you control.

Which file should I edit on Zsh
Use ~/.zprofile for login shells on Zsh. You can also set the variables in ~/.zshrc for interactive shells. Behavior depends on how your session is started.

Glossary

EDITOR – environment variable used by many tools to decide which editor to run.
VISUAL – similar to EDITOR but often takes precedence.
crontab -e – command that opens your user’s cron table for editing.
Shared hosting – multiple customer accounts share one server with limited privileges.
SSH – secure remote shell for command line access.
Shell – program that interprets commands, for example Bash or Zsh.
Home directory – your personal directory on the system, for example /home/username.
Vim modes – Normal mode for commands and Insert mode for typing text.

Durchschnittliche Bewertung 0 / 5. Bewertungen: 0

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top