Nano Text Editor

Nano is a simple console text editor for Unix-like systems. It is installed on most Linux servers and is a good choice for quick edits of configuration files over SSH.

Installing Nano

Nano is available in the standard repositories of all common Linux distributions, so you can install it with one command:

On Ubuntu and Debian:

sudo apt install nano

On AlmaLinux and Rocky Linux:

sudo dnf install nano

The Nano Interface

The nano window has four parts. The top line shows the editor version, the file name and whether the file has unsaved changes. Below it is the editing area. The status bar under the editing area shows messages. The two bottom lines list the main shortcuts: ^ means Ctrl, and M- means Alt (you can also press Esc and then the key).

Keyboard Shortcuts

KeysAction
Ctrl+G or F1Show help
Ctrl+X or F2Exit nano
Ctrl+O or F3Save the file
Ctrl+J or F4Justify the current paragraph (paragraphs are separated by blank lines)
Ctrl+R or F5Insert another file into the current one
Ctrl+W or F6Search in the file
Ctrl+Y or F7Move one page up
Ctrl+V or F8Move one page down
Ctrl+K or F9Cut the current line
Ctrl+U or F10Paste the cut text
Ctrl+C or F11Show the cursor position
Ctrl+T or F12Run the spell checker (if installed)

Command-Line Options

To open a file, run:

nano filename

You can add options and the line and column where the cursor should start:

nano [options] [+line,column] filename

The full list of options is in the help:

nano -h

Options that are useful when you start working with nano:

KeysAction
-hShow the help
+line,columnOpen the file at the given line and column
-SScroll line by line instead of by half a screen (default in recent versions)
-cConstantly show the cursor position
-iAutomatically indent new lines
-vOpen the file in read-only mode
-wDisable wrapping of long lines
-xHide the two help lines at the bottom
-BSave backup copies of files

Editing in Nano

The basic editing operations (M means Alt, or Esc followed by the key):

KeysAction
Alt+AStart selecting text
Ctrl+KCut the selected text
Alt+6Copy the selected text
Ctrl+UPaste
Alt+UUndo
Alt+ERedo
Alt+\Go to the first line of the file
Alt+/Go to the last line of the file
Ctrl+_ or Alt+GGo to a line and column
Alt+WRepeat the last search
Alt+}Indent the line
Alt+{Unindent the line
HomeGo to the start of the line
EndGo to the end of the line
Alt+( or Alt+9Go to the start of the paragraph
Alt+) or Alt+0Go to the end of the paragraph
Alt+TCut from the cursor to the end of the file
Alt+JJustify the whole file
Alt+DCount words, lines and characters
Alt+YTurn syntax highlighting on or off

Practice nano on a real server: a BlueVPS Linux VPS gives you full root access over SSH.

Blog
Subscribe to our Newsletter