All Products
Search
Document Center

Cloud Shell:Nano editor

Last Updated:Jun 21, 2026

Nano is a lightweight, intuitive text editor. Learn common operations and shortcut keys for Nano in Cloud Shell.

Install Nano

  • This guide uses Nano 2.9.3. Operations and shortcut keys may differ in other versions.

  • Nano is pre-installed in most Linux distributions. Run nano --version to verify the installation. If Nano is not installed, install it manually following the GNU nano editor FAQ.

  • Cloud Shell is a web CLI provided by Alibaba Cloud. You can use the pre-installed Nano editor in Cloud Shell. What is Cloud Shell?

Shortcut key notation

  • Shortcut key notation:

    • ^<chr>: Hold control and press <chr>.

    • M-<chr>: Hold meta, edit, or Alt and press <chr>.

  • Some Nano shortcuts conflict with browser shortcuts in Cloud Shell (for example, ^W). Use the Esc key as a substitute:

    • Double-press Esc, then enter <chr>. Equivalent to ^<chr>.

    • Press Esc once, then enter <chr>. Equivalent to M-<chr>.

Common operations

Start and exit Nano

  • Run nano in Cloud Shell to open a new empty file. You must specify a filename when saving.

  • Press ^X to exit Nano.

Manage files

  • Open or create a file:

    • From the shell: Run nano with a file path. If the file does not exist, Nano creates it. Examples:

      nano fileName
      nano /etc/fileName
    • Inside Nano: Press ^R then M-F to open a file in a new buffer. If the file does not exist, Nano creates it.

  • Save a file:

    • Press ^S to save. If no filename is set, Nano prompts you to specify one.

    • If you press ^X with unsaved changes, Nano prompts you to save:

      • Press Y to save.

      • Press N to discard changes.

      • Press ^C to cancel and return to the editor.

  • Save as: Press ^O and specify a file path to save the buffer content to a different location.

Cursor movement

  • Move left: ^B or the right key.

  • Move right: ^F or the left key.

  • Move up: ^P or the up key.

  • Move down: ^N or the down key.

  • Go to line: Press ^_, enter the line number, and press Enter.

  • Page up: Press ^Y. The cursor moves to the top of the page.

  • Page down: Press ^V. The cursor moves to the top of the page.

Edit text

  • Delete: Press Backspace to delete the character left of the cursor, or ^D to delete the character right of the cursor.

  • Select: Move the cursor to the start of the selection, press M-A to enter selection mode, then move the cursor to highlight text.

  • Copy: Press M-6 to copy selected text. If no text is selected, copies the current line.

  • Cut: Press ^K to cut selected text. If no text is selected, cuts the current line.

  • Paste: Press ^U to paste from the clipboard. Consecutively cut lines paste as a single block.

  • Search: Press ^W, enter a keyword, and press Enter to find the first match.

  • Replace: Press ^\ or ^R to find and replace text.

  • Justify: Press ^J to reformat the current paragraph.

  • Undo: Press M-U.

  • Redo: Press M-E.

Configure Nano

Customize Nano by editing the .nanorc file in your $HOME directory. Common configurations:

  • Display line numbers: Add set linenumbers to .nanorc, then restart Nano.

  • Auto-indent: Add set autoindent to .nanorc, then restart Nano.

  • All available options are documented in the NANORC reference.

Examples

Enable line numbers

Add set linenumbers to the first line of .nanorc:

  1. Open the configuration file:

    nano ~/.nanorc
  2. At the top of the file, type set linenumbers.

  3. Press ^S to save.

  4. Press ^X to exit.

  5. Run nano to open the Nano editor. Line numbers are displayed on the left.