Getting Started with nano - The Beginner-Friendly Editor Before Vim
Why nano First?
Linux has several text editors. nano stands out for beginners because keyboard shortcuts are always shown at the bottom of the screen — no memorizing required.
Why nano is beginner-friendly
- Shortcuts are always visible at the bottom of the screen
- No special modes — just start typing right away
- Widely available on Linux servers
Opening nano
nano followed by the filename — that's it!nano filename
Example: opening memo.txt
nano memo.txt
If the file doesn't exist yet, nano will create it when you save.
What You See After Opening
GNU nano 6.2 memo.txt ▌ ^G Help ^O Write Out ^W Where Is ^K Cut ^T Execute ^X Exit ^R Read File ^\ Replace ^U Paste ^J Justify
^ symbol means the Ctrl key. So ^O means Ctrl+O.Reading the screen
- Top line: filename
- Middle area: your editing space
- Bottom 2 lines: shortcut reference (
^=Ctrl)
Editing Text
i before typing.Just start typing wherever the cursor is.
Moving around:
| Key | Action |
|---|---|
| Arrow keys | Move cursor |
| Home / End | Start / end of line |
| Page Up / Down | Scroll one screen |
| Ctrl+A | Go to start of line |
| Ctrl+E | Go to end of line |
Deleting text:
| Key | Action |
|---|---|
| Backspace | Delete character before cursor |
| Delete | Delete character after cursor |
| Ctrl+K | Cut entire line |
Saving
Ctrl+O. Think of "O" as "Output" — writing the content out to disk.Press Ctrl+O and nano will ask you to confirm the filename:
File Name to Write: memo.txt
Just press Enter to save with the same name.
To save under a different name, change the filename before pressing Enter.
Exiting
Press Ctrl+X to exit.
If you have unsaved changes, nano asks:
Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES)?
| Key | Action |
|---|---|
| Y | Save and exit |
| N | Exit without saving (discard changes) |
| Ctrl+C | Cancel (go back to editing) |
Key Shortcuts to Know
Start with these 4
| Shortcut | Action |
|---|---|
Ctrl+O |
Save (write to file) |
Ctrl+X |
Exit |
Ctrl+W |
Search |
Ctrl+K / Ctrl+U |
Cut line / Paste line |
More Useful Shortcuts
| Shortcut | Action |
|---|---|
Ctrl+G |
Open help |
Ctrl+C |
Show cursor position (line number) |
Ctrl+V |
Scroll down one page |
Ctrl+Y |
Scroll up one page |
Alt+U |
Undo |
Alt+E |
Redo |
Search and Replace
Ctrl+W searches, and Ctrl+\ does find-and-replace.Search (Ctrl+W)
- Press
Ctrl+W - Type what you're looking for
- Press Enter
To find the next match, press Ctrl+W → Enter again.
Replace (Ctrl+\)
- Press
Ctrl+\ - Enter search text → Enter
- Enter replacement text → Enter
- Confirm each match with Y / N, or press A to replace all
Practical Example: Editing a Config File
sudo in front — like sudo nano /etc/hosts.sudo nano /etc/hosts
Before editing important files
Always make a backup first:
sudo cp /etc/hosts /etc/hosts.bak
Then edit safely with sudo nano /etc/hosts.
Summary
| Task | Key |
|---|---|
| Open a file | nano filename |
| Save | Ctrl+O → Enter |
| Exit | Ctrl+X |
| Search | Ctrl+W |
| Cut a line | Ctrl+K |
| Paste | Ctrl+U |
| Undo | Alt+U |