A Beginner’s Guide to Using Nano in Linux
What is Nano?
Nano is a terminal-based text editor that’s installed by default on many Linux distributions (Ubuntu, Debian, Fedora, etc.). It’s easy to learn and great for quick edits: configuration files, small scripts, notes and most of the text editing stuff.
Nano does most of what a beginner needs without the steep learning curve of editors like Vim or Emacs.
Open and Create Files
To open an existing file or create a new one:
nano hello.txt

If the file exists, Nano opens it. If it doesn’t, Nano will create it when you save.

Basic Workflow: Editing, Saving, and Exiting
Type normally to edit. When you’re ready:
- Save: Ctrl + O (called “Write Out” in Nano). Press Enter to confirm the filename.
- Exit: Ctrl + X.
If you try to directly exit with unsaved changes, Nano prompts you to save. Type Y to save or N to exit without saving. Ctrl-C to cancel and resume editing.

Find, Cut, Copy, Paste
- Search: Ctrl + W. Type your query and press Enter.

- Cut a line: Ctrl + K
- Paste: Ctrl + U
- Copy: Alt + 6 (places a copy in the cut buffer).
- Select text: Ctrl + 6 to start selection, move the cursor, then cut or copy.
Helpful Tips
- Practice in a safe file before editing system files.
- Use sudo nano only for files that require root access (for example, sudo nano /etc/hosts).
- Access Nano’s help anytime with Ctrl + G.

Common Nano Keyboard Shortcuts Cheat Sheet
| Action | Shortcut |
|---|---|
| Open a file | nano filename |
| Save (Write Out) | Ctrl + O |
| Exit Nano | Ctrl + X |
| Get Help | Ctrl + G |
| Cut line | Ctrl + K |
| Paste line | Ctrl + U |
| Copy text | Alt + 6 |
| Mark (select text) | Ctrl + 6 |
| Search for text | Ctrl + W |
| Go to line number | Ctrl + _ |
| Undo | Alt + U |
| Redo | Alt + E |
| Show line numbers | Alt + N |
| Justify paragraph | Ctrl + J |
Tips for New Users
- Practice in a test file before editing system files. For example:
nano test.txt
- Run nano with sudo only when editing protected files (like configuration files or the hosts file):
sudo nano /etc/hosts
Don’t worry about making mistakes, Nano’s built-in help (Ctrl + G) and Undo (Alt + U) features can save the day.
Final Thoughts
Nano is one of those essential Linux tools you’ll use often without realizing it. It’s lightweight, simple, and perfect for quick edits or learning the basics of terminal-based text editing. Once you’re comfortable with Nano, you can explore more advanced editors but for many tasks, Nano does the job beautifully.
Happy editing.