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.
From our partners:
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
Write to a file
After adding content you can save your work by using the shortcut `Ctrl + O` or `Command + O`.
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.
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`.
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`
Search or `Ctrl + G` or `Command + G`
Useful when searching for configuration files.
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
`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
`-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.
For enquiries, product placements, sponsorships, and collaborations, connect with us at [email protected]. We'd love to hear from you!
Our humans need coffee too! Your support is highly appreciated, thank you!