The Nano Text Editor: A Beginner's Guide
Nano is a simple terminal text editor that is installed by default on most Linux distributions. You open a file with nano file.txt, edit it, save with Ctrl+O, and quit with Ctrl+X. The key shortcuts are listed at the bottom of the screen, so you never have to memorize them.
Open a file
Start nano with the file name. If the file does not exist, nano opens a blank buffer and creates it when you save.
Edit like a normal editor
Once inside, just type. Arrow keys move the cursor, Backspace and Delete remove characters, and the shortcut bar at the bottom shows the available commands with the ^ meaning Ctrl.
Save your work
Press Ctrl+O to write the file, then Enter to confirm the name. This keeps you in the editor so you can keep editing or save again.
Exit nano
Press Ctrl+X to quit. If you have unsaved changes, nano asks whether to save them: press y, confirm the name, and you are done.
Search and go to a line
Press Ctrl+W to search within the file, Alt+W to find the next match, and Ctrl+\ to replace text. To jump to a specific line number, press Ctrl+\, no — that is replace; use Ctrl+W then Ctrl+T for line numbers.
If you need more power, try vim. The nano reference page lists every keybinding.
Keep learning
Related guides: VIM for Beginners: The Essential Guide · Linux Redirection and Pipes: A Practical Guide · tmux: A Beginner's Guide to Terminal Multiplexing. Read all tutorials on the Learn Linux blog.