What You'll Learn
You don't always have a graphical text editor on Linux — especially on servers. This guide teaches you two terminal-based editors: Nano (beginner-friendly) and Vim (powerful, everywhere).
Nano — The Beginner's Choice
Nano is simple and shows all available shortcuts at the bottom of the screen.
Opening Nano
nano filename.txt # Open or create a file
sudo nano /etc/hosts # Edit a system file with root privileges
Essential Nano Shortcuts
| Action | Shortcut |
|---|---|
| Save | Ctrl+O then press Enter |
| Exit | Ctrl+X |
| Cut line | Ctrl+K |
| Paste | Ctrl+U |
| Search | Ctrl+W |
| Go to line number | Ctrl+_ |
Nano will ask if you want to save changes when you try to exit. Say yes, confirm the filename, and you're done.
Vim — The Power User's Editor
Vim is pre-installed on almost every Linux system. It has a steep learning curve but is incredibly powerful once you know the basics.
Vim Has Modes
- Normal mode: Default mode. Used for navigation and commands.
- Insert mode: Press i to start typing/editing text.
- Command mode: Press : from Normal mode to run commands.
Essential Vim Commands
| Action | Key |
|---|---|
| Enter Insert mode | i |
| Leave Insert mode | Esc |
| Save and quit | :wq then Enter |
| Quit without saving | :q! then Enter |
| Search for text | /text then Enter |
| Delete a line | dd (in Normal mode) |
| Undo | u |
The "How Do I Exit Vim?" Cheat Sheet
Press Esc # Make sure you're in Normal mode
Type :q! # Quit without saving (if you messed up)
Type :wq # Save and quit (if you're happy)
New to Vim? Run vimtutor for a built-in 30-minute tutorial.
Which Should You Use?
- Nano: Quick edits, beginners, simple config changes.
- Vim: Heavy editing, servers where Nano isn't installed, when you want speed.
Practice Exercise
# With Nano
nano my-notes.txt
# Type some text, Ctrl+O to save, Ctrl+X to exit
# With Vim
vim my-notes.txt
# Press i to type, Esc to leave insert mode, :wq to save and quit
vimtutor # Run the interactive tutorial
Troubleshooting
- Stuck in Vim: Press Esc, type
:q!, press Enter. - Nano says "File not found" on save: Check the filename and make sure you have write permission in that directory.
What's Next?
You can edit files — now learn how Linux manages users and access:
Users, Groups, and Sudo →