Nano is the default terminal-based text editor in Ubuntu and many other Linux distributions. Though it is less complicated to use than the likes of Vim and Emacs, it doesn’t mean Nano cannot be overwhelming to use.
In this beginner’s guide, I’ll show you how to use the Nano text editor. I am also going to include a downloadable PDF cheat sheet at the end of the article so that you can refer to it for practicing and mastering Nano editor commands.
If you are just interested in a quick summary of Nano keyboard shortcuts, please expand the next section.Essential Nano keyboard shortcuts (click to expand)
How to use Nano text editor
I presume that you have Nano editor installed on your system already. If not, please your distribution’s package manager to install it.
Getting familiar with the Nano editor interface
If you’ve ever used Vim or Emacs, you’ll notice that using Nano is a lot simpler. You can start writing or editing text straightaway.
Nano editor also shows important keyboard shortcuts you need to use for editing at the bottom of the editor. This way you won’t get stuck at exiting the editor like Vim.
The wider your terminal window, the more shortcuts it shows.
You should get familiar with the symbols in Nano.
The caret symbol (^) means Ctrl key The M character mean the Alt key
When it says “^X Exit”, it means to use Ctrl+X keys to exit the editor. When it says “M-U Undo”, it means use Alt+U key to undo your last action.
Open or create a file for editing in Nano
You can open a file for editing in Nano like this:
If the file doesn’t exist, it will still open the editor and when you exit, you’ll have the option for saving the text to my_file.
You may also open a new file without any name (like new document) with Nano like this:
You can start writing or modifying the text straightaway in Nano. There are no special insert mode or anything of that sort. It is almost like using a regular text editor, at least for writing and editing.
As soon as you modify anything in the file, you’ll notice that it reflects this information on the editor.