nano is the editor for people who want to edit a config file without first reading a book. It works the way most editors work — type, and characters appear. Every shortcut is printed at the bottom of the screen. There's no modal weirdness, no "how do I exit?" trauma. If you're new to Linux/BSD, nano is the friendly default.
It's preinstalled on most distributions. On a fresh Debian or Ubuntu it's already there; on Arch or FreeBSD a quick package install puts it in place:
# Debian / Ubuntu
sudo apt install nano
# Arch / Manjaro
sudo pacman -S nano
# FreeBSD
sudo pkg install nano
Step 1: Open a file
nano hello.txt
If the file exists, you'll see its contents. If not, nano opens an empty buffer and creates the file when you save.
The bar at the bottom is the user manual
Look at the bottom of the nano window. You'll see lines like:
^G Help ^O Write Out ^W Where Is ^K Cut
^X Exit ^R Read File ^ Replace ^U Paste
The ^ symbol means Ctrl. So ^O means Ctrl+O. M- means Alt (or Esc, then the key) — for example M-U is Alt+U.
This bar is the difference between nano and every other terminal editor. You don't need to memorise anything — the help is always visible.
Step 2: Type some text
Just type. There's no mode to enter or exit. Use arrow keys to move around. Use Home and End to jump to the start and end of a line.
Step 3: Save (Write Out)
Press Ctrl+O. Nano prompts File Name to Write: with the current filename pre-filled. Press Enter to confirm. The file is saved.
If you want to save under a different name (Save As), type the new name before pressing Enter.
Step 4: Exit
Press Ctrl+X. If you have unsaved changes, nano asks whether to save first. Press Y for yes, N for no, or Ctrl+C to cancel and stay in the editor.
Useful editing shortcuts
Ctrl+K # cut the current line (or selection)
Ctrl+U # paste (un-cut)
Ctrl+W # "Where is" — search
Ctrl+ # search and replace
Ctrl+_ # go to line number
Ctrl+G # full help screen
Alt+U # undo
Alt+E # redo
Alt+A # mark / start a selection (then move to select)
To select text without a mouse: press Alt+A, move with arrow keys, then Ctrl+K to cut or Alt+6 to copy. Ctrl+U pastes it back.
Search and replace, step by step
- Press Ctrl+.
- Type the text to find, press Enter.
- Type the replacement, press Enter.
- Nano asks at each match: Y replace, N skip, A all remaining, Ctrl+C cancel.
Helpful flags when starting nano
nano -l file.txt # show line numbers
nano -m file.txt # enable mouse support (click to position cursor)
nano -w file.txt # disable word wrap (good for config files)
nano -B file.txt # make a backup as file.txt~ on save
nano +42 file.txt # open and jump to line 42
Making the defaults stick: ~/.nanorc
If you find yourself typing the same flags every time, set them once in ~/.nanorc:
# show line numbers
set linenumbers
# enable the mouse
set mouse
# don't wrap long lines (useful for config files)
set nowrap
# show a softer "soft" wrap visually only
# set softwrap
# enable syntax highlighting (loads from /usr/share/nano)
include "/usr/share/nano/*.nanorc"
# make a backup file (filename~) on every save
set backup
# tabs are 4 spaces
set tabsize 4
set tabstospaces
Save the file. Every future nano invocation reads it.
Quick-reference cheat sheet
| Ctrl+O | save |
| Ctrl+X | exit |
| Ctrl+G | help |
| Ctrl+W | search |
| Ctrl+ | search + replace |
| Ctrl+_ | go to line |
| Ctrl+K | cut line / selection |
| Ctrl+U | paste |
| Alt+U | undo |
| Alt+E | redo |
| Alt+A | start selection |
| Alt+6 | copy selection |
When to use nano vs vim
Nano is perfect for quick edits: changing a line in /etc/hosts, adjusting a config file, scribbling a commit message. Once you're comfortable on Linux and start editing a lot of code, you'll probably outgrow it and learn Vim. There's no shame in either choice — nano gets a real job done with no learning curve, and that's a quality worth respecting.