Skip to content

Using Nano

Use nano when you need a simple terminal editor for config files, credentials, commit messages, or quick text edits.

Open an existing file or create it if it does not exist.

Terminal window
nano FILE_NAME

Open a file at a specific line.

Terminal window
nano +LINE_NUMBER FILE_NAME

Open a file with line numbers visible.

Terminal window
nano --linenumbers FILE_NAME

Nano shows common shortcuts at the bottom of the editor.

^ means Ctrl, so ^X means Ctrl+X.

M- means Meta, which is usually Alt or Esc, so M-U means Alt+U or Esc, then U.

Open the file.

Terminal window
nano FILE_NAME

Edit the text normally.

Save changes.

Ctrl+O
Enter

Save changes with a different file name.

Ctrl+O
NEW_FILE_NAME
Enter

Exit nano.

Ctrl+X

If nano asks whether to save a modified file, press Y to save or N to discard. Press Enter to confirm the file name when saving.

Search with Where Is.

Ctrl+W

Find the next match.

Alt+W

Find the previous match.

Alt+Q

Replace text.

Ctrl+\

Cut the current line. This works like deleting the whole line unless you paste it back.

Ctrl+K

Copy the current line.

Alt+6

Paste the cut or copied text.

Ctrl+U

Start or stop selecting text.

Alt+A

Move the cursor to expand the selection, then cut or copy the selected text.

Ctrl+K
Alt+6
CommandMeaning
nano FILE_NAMEOpen or create a file.
nano +LINE_NUMBER FILE_NAMEOpen a file at a specific line.
nano --linenumbers FILE_NAMEOpen a file with line numbers visible.
Ctrl+GOpen nano help.
Ctrl+OWrite out the file, usually used to save changes.
Ctrl+SSave the current file in nano versions that support it.
Ctrl+XExit nano.
Ctrl+RRead another file into the current file.
Ctrl+WSearch with Where Is.
Ctrl+\Start search and replace.
Alt+RStart search and replace in nano versions that support it.
Alt+WFind the next search match.
Alt+QFind the previous search match.
Ctrl+KCut the current line or selected text. Use this to delete a whole line.
Ctrl+UPaste cut or copied text.
Alt+6Copy the current line or selected text.
Ctrl+TExecute a command or open tool actions from some prompts.
Ctrl+JJustify the current paragraph or selected text.
Ctrl+CShow the current cursor position.
Ctrl+/Go to a specific line.
Alt+GGo to a specific line in nano versions that support it.
Alt+AStart or stop selecting text.
Alt+UUndo.
Alt+ERedo.
Alt+]Jump to the matching bracket.
Alt+OGo to the previous item in contexts that support it.
Ctrl+BMove back one character.
Ctrl+FMove forward one character.
Ctrl+LeftMove to the previous word.
Ctrl+RightMove to the next word.
Ctrl+AMove to the start of the current line.
Ctrl+EMove to the end of the current line.
Ctrl+PMove to the previous line.
Ctrl+NMove to the next line.
Alt+NToggle line numbers.
Alt+SToggle soft wrapping.