nano Basics
You're SSH'd into a server. You need to edit a config file. No VS Code, no GUI. This is where terminal editors shine.
nano is the beginner-friendly choice. It shows you what to do at the bottom of the screen.
Open a File
If the file doesn't exist, nano creates it when you save.
The nano Interface
GNU nano 6.2 /etc/hosts
127.0.0.1 localhost
127.0.1.1 mycomputer
# The following lines are desirable for IPv6
::1 ip6-localhost ip6-loopback
^G Help ^O Write Out ^W Where Is ^K Cut ^U Paste
^X Exit ^R Read File ^\ Replace ^J Justify ^T Spell
The bottom two lines show keyboard shortcuts. ^ means Ctrl.
Essential Shortcuts
| Shortcut | Action |
|---|---|
Ctrl+O | Save (Write Out) |
Ctrl+X | Exit |
Ctrl+K | Cut line |
Ctrl+U | Paste |
Ctrl+W | Search |
Ctrl+G | Help |
Save and Exit
Or save and exit in one go:
- Press
Ctrl+X - nano asks "Save modified buffer?"
- Press
Y(yes) - Confirm filename with Enter
Editing Text
Just type. nano works like any normal editor. Arrow keys move the cursor.
Search and Replace
Search
Search and Replace
Cut, Copy, Paste
Copy Without Cutting
nano Is Always Available
nano is installed on virtually every Linux system. When you can't remember vim commands or the server doesn't have your favorite editor, nano is there.
Go to Line Number
Or open directly at a line:
How do you save a file in nano?
Quick Reference
| Shortcut | Action |
|---|---|
Ctrl+O | Save |
Ctrl+X | Exit |
Ctrl+K | Cut line |
Ctrl+U | Paste |
Ctrl+W | Search |
Ctrl+\ | Replace |
Ctrl+_ | Go to line |
Ctrl+G | Help |
Key Takeaways
- nano shows shortcuts at the bottom (
^= Ctrl) Ctrl+Osaves,Ctrl+XexitsCtrl+Kcuts,Ctrl+UpastesCtrl+Wsearches- Perfect for quick edits when you need something simple
- Available on almost every Linux system
Next: introduction to vim - the powerful (and intimidating) editor.