How to Use nano Editor in Linux?

In Linux, the nano is a Powerful Text Editor that’s been around for a long time and helps to edit files on system terminals. It serves multiple purposes, i.e., creates/edits text, code, and config files. Apart from that, it has a variety of shortcuts that makes the editing operations more effective.

This post describes the complete usage of the “nano” editor. The supported content of this post is as follows:

  • Prerequisites: Check the Nano Editor
  • How to Use Nano Editor in Linux?

Prerequisites: Check the Nano Editor

Before using the “nano” text editor, verify whether the “nano” is installed in the current working Linux system. To perform this task, follow the below-mentioned steps:

Step 1: Check the nano Editor Status

By default, the “nano” text editor is pre-installed in most Linux distributions, especially in Ubuntu. Type the following command in the terminal and press the enter key to check the “nano” editor version:

$ nano --version

The output shows the installed “nano”versionis “6.2”.

Step 2: Install the nano Editor (Recommended)

If the “nano” editor is not available in the Linux system, then install it by using the below command according to your Linux distribution:

On Ubuntu and Debian

$ sudo apt install nano

For CentOS and RHEL (Older Versions)

$ sudo yum install nano

For Fedora/CentOS/RHEL

$ sudo dnf install nano

How to Use the Nano Editor in Linux?

If the Nano editor is ready to launch on your system, type the following command to open it:

$ nano

The interface of the “nano” editor will open up. Its window contains three sections such as

  • Title bar: The title bar shows the latest version of the “nano” editor on the left side and the file name in the center.
  • Canvas: it is the text editing section that is used to write the specific file content.
  • Commands: The last section displays the various commands that help perform different operations in the file. These basic commands are listed below, along with their description.
Ctrl + AMove the cursor at the start of the line.
Ctrl + EMove the cursor at the end of the line
Ctrl + YScroll the page up.
Ctrl + VScroll down the page.
Ctrl + OAsk to edit the file name.
Ctrl + GDisplay the help page that contains all commands.
Ctrl + WSearch for the particular mentioned phrase.
Ctrl + CRepresents the cursor point character information like (line, column, char)
Ctrl + JJustified the line or paragraph at the cursor point.
Ctrl + UPaste the text cut from the specific line.
Ctrl + KCut the text at the cursor point
Ctrl + SSave the created or edited file.
Ctrl + XExit the nano editor window.
Ctrl + –Zoom out the “nano” editor window
Ctrl + \Ask for the word to search and replace.

To get more options and information about the “nano” editor, press the “Ctrl+G” shortcut key. It will provide the help page of the “nano” editor:

Let’s practice a few examples of using nano on Linux.

Example 1: Create/Edit the File Text

A nano editor can be used to create a file, and if the file is already created, you can edit its content.  For this purpose, “the nano” editor provides very useful shortcut keys described below:

Select the Text

First and move the mouse cursor at the starting point of the specific line or paragraph. Press the “Alt+A” shortcut key. It will set the “Mark” as shown in the screenshot:

Now, move the cursor to the desired place by pressing the “right-arrow” key using the keyboard:

The specific line has been selected.

Copy and Paste the Text

Press the “Alt+6” shortcut key to copy the above-selected text. Navigate to the place where you want to paste the text and press the “Ctrl+U” shortcut to paste it:

The selected text is copied and pasted into the desired place

Cut the Text

The selected text of the file can also be cut by utilizing the “Ctrl+K” shortcut key. Suppose in the “NewFile” the highlighted line is selected for this purpose:

Press the “Ctrl+K” shortcut key. The selected line will be cut from the file. After that paste it at another place where you want via the “Ctrl+U” shortcut key:

Example 2: Search and Replace the File Text

In the “nano” editor the user can also search and replace the words in the specific text file with the help of shortcut keys.

Search a Word

Press the “Ctrl+W” for searching a word. It will ask for the specific “word” that you want to be searched for:

Enter the search word and press the “Alt+W” to search the word in a whole file continuously as  shown in the below screenshot:

The searched word is “freedom” and is highlighted as shown in the above screenshot.

Search and Replace Searched Word

To search and replace at a time press the “Ctrl+\” key to replace the word “to” with the new word “from”:

After that hit the “Enter” key and write the keyword “from” that will replace in place of “to”:

Select the option “Y” for yes and “A” for all the instances. In this case, hit the “A” option:

After pressing “A” the word “to” is replaced with “from” at every instance as shown below:

Example 3: Save and Close File

When the file is completely edited or created then press the “Ctrl+S” to save the file. But if you want to change the current file name then press the “Ctrl+O” key. It will save the new changes and ask for modifying the file name:

Modify the current file name and press the “Enter” key:

Enter the “Y(yes)” for changing the file name. Otherwise type “N” for “not”  and “C” for “cancel”.

In last use the “Ctrl+X” shortcut key to exit the “nano” editor window or close the file. It will ask for permission either to save the changes or not. Enter the “Y(Yes)” to save the changes or “N(Not)” to ignore them. In our case, entered “Y” to save the new changes in the file:

After that press, the “Enter” key, and the “nano” editor will be closed.


Linux and most of its distributions provide the “nano” editor by default. If it is not already installed, then use the “$ sudo apt install nano” command to install it into the “Ubuntu” system. However,  it’s a great skill to have if you like being efficient while browsing a file system and not having to use a graphical method in order to make changes to a file. This post briefly illustrated the installation, working, and usage of the “nano” editor in Linux.