nano
Editor
nano
is a simple and easy-to-use terminal-based text editor.- Ideal for quick edits or configuration file changes.
- Lighter and more intuitive than
vim
oremacs
.
Syntax
nano filename
- Opens
filename
for editing. - If the file doesn’t exist, it creates a new one.
Basic Navigation
Key | Action |
---|---|
Ctrl + A | Move to beginning of line |
Ctrl + E | Move to end of line |
Ctrl + Y | Scroll up one page |
Ctrl + V | Scroll down one page |
Ctrl + _ | Go to specific line and column |
Editing Text
- Use arrow keys to move.
- Type as you normally would.
- Supports copy, cut, paste operations.
Saving and Exiting
Key | Action |
---|---|
Ctrl + O | Write out (Save) file |
Enter | Confirm filename to save |
Ctrl + X | Exit nano |
Ctrl + C | Cancel current action |
Cutting, Copying, and Pasting
Key | Action |
---|---|
Ctrl + K | Cut the current line |
Ctrl + U | Paste the cut line |
Ctrl + ^ | Set mark (start selection) |
Arrow keys | Extend selection |
Ctrl + K | Cut selected region |
Searching and Replacing
Key | Action |
---|---|
Ctrl + W | Search |
Ctrl + \ | Search and replace |
Ctrl + R | Insert file contents at cursor |
Enabling Line Numbers (optional)
nano -c filename
- Shows the current cursor position.
Example: Edit /etc/hosts
sudo nano /etc/hosts
- Make changes to the hosts file, save with
Ctrl + O
, exit withCtrl + X
.
Summary of Common Shortcuts
Shortcut | Description |
---|---|
Ctrl + O | Save (write out) |
Ctrl + X | Exit |
Ctrl + K | Cut line or region |
Ctrl + U | Paste |
Ctrl + W | Search |
Ctrl + \ | Replace |
Ctrl + ^ | Start marking selection |
Ctrl + G | Help |
Last updated on