Nano is a text editor for Linux, a default in Ubuntu. It is a simple editor, unlike VI. It might not be as powerful, but for simple things like editing configuration files, it does the job well.
01. Nano stands for …
Nano is an acronym for “Nano’s ANOther editor”. Which is inspired by Pico.
02. How to install nano
Ubuntu and Debian
sudo apt install nano
CentOS and Fedora
sudo yum install nano
03. Basics
Opening nano
Can execute it without any parameters. This opens an editor in a buffer. You can interact with, but you would need to write to a file in order persist it in the disk.
nano
![](https://cyberpogo.com/wp-content/uploads/2023/10/abcs-of-nano-editor_01.png)
Write to a file
After adding content you can save your work by using the shortcut `Ctrl + O` or `Command + O`.
![](https://cyberpogo.com/wp-content/uploads/2023/10/abcs-of-nano-editor_02.png)
Indicate the name of the file. Remember that when you opened the editor? It will be written in the same directory where `nano` was executed. Press enter after setting the file name.
![](https://cyberpogo.com/wp-content/uploads/2023/10/abcs-of-nano-editor_03.png)
Exit the editor
To exit from the editor, use the shortcut `Ctrl + X` or `Command + X`
View the file created using the `ls` command. Or read it using `cat`.
![](https://cyberpogo.com/wp-content/uploads/2023/10/abcs-of-nano-editor_04.png)
Opening a file
If a file is not yet existing, it will create a new one.
nano another greetings.txt
04. Shortcuts
Help
Opens the complete list of shortcuts using `Ctrl + G` or `Command + G`
![](https://cyberpogo.com/wp-content/uploads/2023/10/abcs-of-nano-editor_05.png)
Search or `Ctrl + G` or `Command + G`
Useful when searching for configuration files.
![](https://cyberpogo.com/wp-content/uploads/2023/10/abcs-of-nano-editor_06.png)
Type the text to search and press Enter. Pressing enter multiple times, will skim through the file and find the next occurrence.
05. Opening a file with different options.
Show line numbers
nano /path/to/file -l
![](https://cyberpogo.com/wp-content/uploads/2023/10/abcs-of-nano-editor_07.png)
![](https://cyberpogo.com/wp-content/uploads/2023/10/abcs-of-nano-editor_08.png)
`l` or `–linenumbers`. Sometimes you already have a copy of a file in your local machine. For example a settings.json and you need to update this configuration quickly on your development environment. If you know the line number, it’s easier to find it.
Having backups
nano /path/to/file -B
![](https://cyberpogo.com/wp-content/uploads/2023/10/abcs-of-nano-editor_09.png)
![](https://cyberpogo.com/wp-content/uploads/2023/10/abcs-of-nano-editor_10.png)
`-B` or `–backup` will save the previous version of the edited file with ‘~’ at the end. This is not like a versioning system, but it’s a good safeguard when dealing with configuration files.
Nano is an efficient editor and it does it job well. In most cases when you’re just visiting a server and making some tweaks, it will be sufficient.
Thank you ZedOptima for sponsoring this article.
Our humans need coffee too! Your support is highly appreciated, thank you!