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 nanoOn AlmaLinux and Rocky Linux:
sudo dnf install nanoThe 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
| Keys | Action |
|---|---|
| Ctrl+G or F1 | Show help |
| Ctrl+X or F2 | Exit nano |
| Ctrl+O or F3 | Save the file |
| Ctrl+J or F4 | Justify the current paragraph (paragraphs are separated by blank lines) |
| Ctrl+R or F5 | Insert another file into the current one |
| Ctrl+W or F6 | Search in the file |
| Ctrl+Y or F7 | Move one page up |
| Ctrl+V or F8 | Move one page down |
| Ctrl+K or F9 | Cut the current line |
| Ctrl+U or F10 | Paste the cut text |
| Ctrl+C or F11 | Show the cursor position |
| Ctrl+T or F12 | Run the spell checker (if installed) |
Command-Line Options
To open a file, run:
nano filenameYou can add options and the line and column where the cursor should start:
nano [options] [+line,column] filenameThe full list of options is in the help:
nano -hOptions that are useful when you start working with nano:
| Keys | Action |
|---|---|
| -h | Show the help |
| +line,column | Open the file at the given line and column |
| -S | Scroll line by line instead of by half a screen (default in recent versions) |
| -c | Constantly show the cursor position |
| -i | Automatically indent new lines |
| -v | Open the file in read-only mode |
| -w | Disable wrapping of long lines |
| -x | Hide the two help lines at the bottom |
| -B | Save backup copies of files |
Editing in Nano
The basic editing operations (M means Alt, or Esc followed by the key):
| Keys | Action |
|---|---|
| Alt+A | Start selecting text |
| Ctrl+K | Cut the selected text |
| Alt+6 | Copy the selected text |
| Ctrl+U | Paste |
| Alt+U | Undo |
| Alt+E | Redo |
| Alt+\ | Go to the first line of the file |
| Alt+/ | Go to the last line of the file |
| Ctrl+_ or Alt+G | Go to a line and column |
| Alt+W | Repeat the last search |
| Alt+} | Indent the line |
| Alt+{ | Unindent the line |
| Home | Go to the start of the line |
| End | Go to the end of the line |
| Alt+( or Alt+9 | Go to the start of the paragraph |
| Alt+) or Alt+0 | Go to the end of the paragraph |
| Alt+T | Cut from the cursor to the end of the file |
| Alt+J | Justify the whole file |
| Alt+D | Count words, lines and characters |
| Alt+Y | Turn syntax highlighting on or off |
Practice nano on a real server: a BlueVPS Linux VPS gives you full root access over SSH.
Blog