Basic Nano interface with key shortcuts displayed
What is Nano?
Nano is a beginner-friendly command-line text editor in Linux. Unlike complex editors like Vim, Nano shows common shortcuts at the bottom of the screen, making it perfect for newcomers. Here are 30 essential commands to master Nano:
🚀 Basic Operations
-
Open a file
nano filename.txt
Creates or opens existing file -
Save changes
Ctrl + O
→ Press Enter
Write Out changes to disk -
Exit Nano
Ctrl + X
Exits editor (prompts to save unsaved changes) -
Save & Exit
Ctrl + X
→Y
→ Enter
Fast save-and-quit combo
Saving confirmation prompt in Nano
✏️ Editing Commands
-
Undo action
Alt + U
Reverts last edit -
Redo action
Alt + E
Re-applies undone edit -
Cut entire line
Ctrl + K
Removes current line -
Paste text
Ctrl + U
Inserts cut/copied content -
Copy text
Alt + ^
(Ctrl+6)
First set mark withCtrl + ^
-
Delete character
Ctrl + D
Deletes under cursor
🔍 Navigation Shortcuts
-
Move cursor
Arrow keys
Basic navigation -
Jump to line
Ctrl + _
→ Type line number
Go directly to specific line -
Page up/down
Ctrl + Y
/Ctrl + V
Scroll through document -
Start of line
Ctrl + A
Moves to line beginning -
End of line
Ctrl + E
Moves to line end -
Start of file
Alt + \
Jump to first line -
End of file
Alt + /
Jump to last line
🔎 Search & Replace
-
Find text
Ctrl + W
→ Type search term
Basic search -
Find next occurrence
Alt + W
Repeats last search -
Replace text
Ctrl + \
Search and replace mode -
Case-sensitive search
Alt + C
to toggle
Enable/disable case matching
🛠️ Advanced Functions
-
Insert file
Ctrl + R
→ Filename
Embed another file’s content -
Spell check
Ctrl + T
Requires spell package installed -
Auto-indent toggle
Alt + M
Enable/disable auto-indentation -
Show cursor position
Ctrl + C
Displays line/column info -
Multiple buffers
Alt + ,
/Alt + .
Switch between open files
Working with multiple files in Nano
💾 File Operations
-
Save as new name
Ctrl + O
→ New name → Enter
Creates copy with different filename -
Insert backup file
Ctrl + R
→filename.save
Recover from automatic backups
⚙️ Configuration Tips
-
Enable line numbers
Alt + Shift + #
Toggle line numbering -
Syntax highlighting
Install with:
sudo apt install nano-syntax
Enable in config:
include /usr/share/nano/*.nanorc
Pro Tip:
Create ~/.nanorc
file with these lines for permanent settings:
set autoindent
set tabsize 4
set linenumbers
> 💡 Did You Know? Nano automatically creates .save
backup files when editing system files – your safety net against accidental changes!
Master these 30 commands and you’ll efficiently edit configuration files, scripts, and documents directly in the terminal. Happy editing! 🐧