Home·Terminal commands

nano

Text processing

Usage

nano [file]

A plain full-screen editor with its commands printed at the bottom; the caret in ^O and ^X means Ctrl, not a literal character.

Common flags

FlagMeaning
Ctrl-OWrite the file out; the caret in ^O means Ctrl
Ctrl-XLeave nano, offering to save first
Ctrl-WSearch; Alt-W repeats the search
-wDo not wrap long lines, which config files need
-BKeep a backup of the file as it was
+NOpen with the cursor on line N
--linenumbersShow line numbers (nano 4.0 and later)

Examples

sudo nano /etc/hosts

Ctrl-O to write, Ctrl-X to leave.

nano -w /etc/nginx/nginx.conf

No line wrapping, so directives stay on one line.

nano +25 deploy.sh

Opens at line 25.

These were built to be piped together. Three joined commands are usually shorter than one that does everything.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does nano do?

A plain full-screen editor with its commands printed at the bottom; the caret in ^O and ^X means Ctrl, not a literal character.

Q. How do I type it?

nano [file] — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

7 are listed here; the full set is in man nano. This command sits under Text processing.

Related commands

man page: man nano