On modern *nix systems there are heaps of editors available. I’ll cover the minimal basics of two of the most common, nano and vim, which are available on most systems.

Some commands, such as crontab -e to edit the current cron table, need to open an interactive editor. The choice of editor is controlled by $VISUAL, which is usually just a command to run such an editor:

To set a specific default editor we can set the $VISUAL variable in ~/.bashrc.


nano is probably the most beginner–friendly terminal editor around. To start editing a new or existing file simply run nano FILE. If FILE does not yet exist it will not be created until you save within the editor, and if FILE does exist it will be opened and syntax highlighted if applicable. At this point you’ll notice a sort of menu at the bottom of the screen, which shows a number of options depending on the width of the terminal window. The options start with a caret (^) character, which is a common symbol for the Ctrl key. The characters after the caret are all uppercase, but you don’t need Shift or Caps Lock to use them, so the ^X shortcut corresponds to Ctrl–x. When exiting, nano will ask whether you want to save your changes. Ctrl–g shows a help page with more options and descriptions.


This page is a preview of The newline Guide to Bash Scripting

No discussions yet