Edit files in the terminal with nano
The beginner-friendly terminal editor: open, edit, save and exit a file with on-screen shortcuts.
01Command
$ nano /etc/hosts02What it does
nano shows its key bindings on screen at all times, which makes it the go-to editor for quick config fixes. Ctrl+K cuts a line and Ctrl+U pastes it, Ctrl+W searches, and Ctrl+_ (or Alt+G) jumps to a line number — handy when a log or compiler error names one. Add -w for files where line wrapping would corrupt the layout, and -l to show line numbers.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- nano(1) - a small, friendly text editorEvidence: nano edits files with on-screen key hints; ^O writes out, ^X exits, -w disables wrapping (important for config files).
- GNU nano documentationEvidence: Official nano manual covering shortcuts, ^K/^U cut-paste, ^W search and syntax highlighting configuration.
Last verified: 2026-09-18 · Category: Developer
06Related solutions
Find every occurrence of a pattern across all files in a tree, printed as file:line:number matches.
Unpack a gzipped tarball into the current directory while printing each file as it is extracted.
Add or remove read, write, and execute permission for the owner, group, or others using symbolic or octal modes.