Nano Commandline Editor Tutorial for Beginners 2021

In this short tutorial I will show you the basics of using the nano editor. I will use Ubuntu for that, but once you’ve installed nano on your system, the usage won’t be any different.

Installation

If not already present on your system you can install nano on Ubuntu with the following command:

sudo apt install nano -y

You can also test if you’ve already installed it by typing:

sudo nano text.txt

If a editor windows pops up, you are good to go. If nano isn’t present on your system you will see an error like “bash: /usr/bin/nano: No such file or directory

Since you already open the editor for a “text.txt” test-file, you can continue with the editor’s controls.

Controls

If not already done, open a file you want to write to:

cd ~/PATH_TO_FILE_DIR/  # e.g. cd ~/nano_example/
nano FILENAME  # e.g. example.txt

Depending on the location of your file and your current user it might be necessary to use root or sudo.

# becoming root user (permanently)
sudo su

# executing only this command with superuser rights
sudo COMMAND  # e.g. sudo nano test.txt

Learn more about the Linux commandline.

Now you are looking at a screen similar to this one:

1. Typing

Typing in Nano is quite self-explanatory since you only need to write your text with your keyboard if you want to change the text. You, of course, can use Spaces, Tabs, Linebreaks, etc. in your text. The cursor position can be changed with the arrow keys (up-down for a line change, right-left for next/previous character).

2. Navigation

In order to navigate within your text is can be quite helpful to know some basic navigation controls. e.g. if you are navigating a long text.

  1. Go to line: CTRL+SHIFT+UNDERSCORE then enter line number and ENTER
  2. Search for String: CTRL+W then enter text and ENTER
3. Controls

Saving a file: CTRL+O then enter

Closing nano: CTRL+X

Selecting (& cutting) text areas: via mouse highlighting or by setting a mark (ALT+M+A) and navigating in text with arrow-keys.

Cut: CTRL+K

Paste: CTRL+U

Scaling the text: make bigger: CTRL+SHIFT+”+” / make smaller: CTRL+”-“

Help menu (list of all commands): CTRL+G

Conclusion

Nano, of course, provides many other shortcuts and controls. But in this tutorial, I just wanted to point out the most important features to get started with nano. Since experienced users that could potentially be interested in other controls wouldn’t read this tutorial anyway, I don’t want to overcomplicate things.

You can the other controls in the help menu which can be accessed via CTRL+G. Some other controls are also depicted at the bottom of the editor.

Leave a Reply