Using the nano Text Editor

nano is a simple text editor that works like most desktop editors: you just start typing. It is installed on Ubuntu and many other systems, and is a good choice if you only need to change a setting now and then.

Opening files

nano file.txt
Opens file.txt, or starts a new file with that name.
sudo nano /etc/hosts
Opens a system file. You need sudo to save changes to files outside your home directory.
nano -l config.conf
Shows line numbers down the side.

Using nano

The shortcuts are listed at the bottom of the screen. ^ means the Ctrl key and M- means the Alt key.

KeyWhat it does
Ctrl + OSave (write out). Press Enter to confirm the name
Ctrl + XExit. You'll be asked to save if there are changes
Ctrl + WSearch
Ctrl + \Search and replace
Ctrl + KCut the current line
Ctrl + UPaste
Ctrl + _Go to a line number
Alt + UUndo
Ctrl + GHelp