How to install and use nano text editor

How to install and use nano text editor

The Linux distribution has several editors, some of which are more popular than other editors due to their ubiquity and ease of use. Among the editors in this field are VI, VIM and Nano. One of the reasons Nano Editor is so popular with other editors is the way it is edited and worked with. So that after executing this command in the Linux terminal, it is as if it has given you a graphic mode for text editing, which makes the editing process easier and faster. That’s why we decided to teach how to install and use nano text editor.

How to install and use nano text editor

In this tutorial you will learn how to install and use Nano text editor. Nano Learning will enable you to edit text files on your VPS command line when you are logged in using SSH. While Vim and Emacs are used by novice Linux users, the Nano is much easier to use. That is why it is one of the most popular text editors for Unix systems.

In this tutorial, you will learn how to install Nano on Ubuntu and CentOS. In addition, some basic nano commands for text editing are taught.

Recommended Article: How to Find MySQL PHP and Apache Configuration Files

Prerequisites for installing and using Nano Text Editor

Access to a machine running Ubuntu or CentOS (SSH remote access to a machine running one of these operating systems also works).

How to install Nano Text Editor

The installation process of Nano Text Editor depends on your operating system. In general, Nano is pre-installed on some operating systems and users can use the Nano Text Editor. But if this item is not installed or you are not familiar with it, first install Nano Text Editor, then read the necessary instructions when working with it in the rest of the article.

How to install Nano Text Editor in Debian / Ubuntu

To install the Nano text editor on Debian or Ubuntu operating systems, run the following command:

sudo apt-get install nano

Wait for the installation process to complete and the Nano Text Editor installation is complete.

Note: The sudo section is intended to run this command as a root user. You may be asked to enter your password if you may not have logged in with the root user from the beginning. So no worries.

How to install Nano Text Editor on CentOS / RHEL

To install Nano Editor on CentOS or RHEL operating systems, run the following command:

yum install nano

This command starts the Nano Text Editor installation. Once the settings are complete, you can use it!

The following command will open a Nano text editor page for you. If you make any changes to the text, they will be saved as test.txt. CTRL + X keys can be used to close the nano. You will then be asked Do you want to save the file changes? Enter Y for a positive answer and then press enter.

nano test.txt

Here’s how to use the Nano Editor. The items we will cover:

How to open and close files and edit

Nano Editor Tips and Tricks

Search and replace text

Check basic commands

How to open and close Nano text editor

The main command to open the editor is as follows:

nano filename

Note: You can enter the name of the desired or new file instead of the file name. Note that if you want to edit a pre-existing file, you must be in the directory where the file is located. You can also specify the full file path.

For example, to open a file in the directory you are in, you can use the following command:

nano test.txt

To open a file in another directory:

nano /path/to/directory/test.txt

Note: Nano creates a new file from the given file name if that file does not exist in the directory. If no file name is specified, an untitled and empty file will be created and the file name will be asked when leaving the editor if there is any change.

After executing the command, you will be taken to the editor window. In this window you are able to edit text with Nano Text Editor. Use the arrow keys on your keyboard to move the cursor around the text.


nano text editor


At the bottom of this window, there are shortcuts by which you can use the nano text editor. The ^ Symbol means that you must press CTRL + [key] (CMD + [key] for Mac users) to execute the command you want.

Press CTRL + O to save the changes to the file and continue editing.

Use CTRL + X to exit the editor. If any changes are made to the file that is currently open, it will ask you if you want to save it. If you want to save the changes, enter y and then press enter.

Note: Use the -w option whenever you want to open a configured file in Nano. By default, Nano rotates text to fit the screen. This can corrupt some configured files and cause a lot of problems.

For example, to open a configured file, use the following command:

sudo nano -w /etc/apache2/apache2.conf

Nano Editor Tips and Tricks

To select the text, go to the beginning of the selected text and press the ALT + A keys. This will set a check mark to select.

Then scroll through the text to select the text with the arrow keys. This selects the text.

Use the ALT + 6 keys to copy the selected text. This will copy the text to the clipboard.

Use CTRL + K to cut the text.

Press CTRL + U to paste the text.

If no text is selected before copying or pasting, it will copy or paste the entire line.

Search and replace text

Press CTRL + W to search for text. This will ask you about the text you want to search. Enter the text you want and press enter. Use ALT + W to search for similar text.

To find and replace text, press CTRL + W and then CTRL + R. This will ask for the text you want to search for as well as the text you want to replace. This will take you to the first instance of the text and ask you if you want to replace this part or all of the events.

Here are some basic nano commands used when editing text:

CTRL + A: Go to start line

CTRL + E: Go to the end of the line

CTRL + Y: Scroll text down

CTRL + V: Move text up

CTRL + G: This command opens a help window that displays a list of all commands that can be used in Nano.

CTRL + O: The basic command to save. When used, you will be prompted to edit or confirm the file name and save your file by pressing Enter.

CTRL + W: One of the most useful nano commands. Used to search for a specific phrase in your text. This is very similar to the usual CTRL + F command in other programs and operating systems. Use ALT + W to search again for a similar phrase.

CTRL + K: Cuts the entire selected line and takes it to the cut buffer.

CTRL + U: Paste text from the cut buffer on the selected line.

CTRL + J: Justify the current paragraph

CTRL + C: Displays the current location of the cursor in the text (line / paragraph / column)

CTRL + X: By using this command, the nano software can be closed. If there is any change in the text, a save message will appear immediately.

CTRL + R: Open a file with the “Read File” command. Inserts the file from disk into the current cursor location.

CTRL + \: Replaces a regular string or phrase.

CTRL + T: Use a spell checker, if applicable.

_ + CTRL: Go to the specified row and column number.

ALT + A: Select text. First move the cursor to the text you want to select, then press ALT + A. The text will then be selected by moving the cursor with the arrow keys to the right. You can combine this command with CTRL + K and cut the selected text and move it to the cut buffer.

These commands were the basic commands and the most useful and used nano commands. If you need more commands, do not forget CTRL + G, this command will take you to the nano commands window.


In this tutorial, you will learn how to install and use a nano text editor. Note that depending on the Linux operating system you have, you must enter the relevant command in the command line environment. There are some basic instructions and practical keys that can help you edit your files faster and easier, as mentioned above. You do not need to install Nano next time and just use the file editing command.

How useful was this post?

Click on a star to rate it!

Average rating 1 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

10 thoughts on “How to install and use nano text editor

    1. It supports two types of scrolling. One chunk-by-chunk that scrolls multiple lines and one line-by-line that scrolls line by line.

    1. nano by default, uppercase and lowercase letters do not matter. If you want to make the nano search case, add the following line to the configuration file:
      set casesensitive

    1. If you need to access the search / replace history in nano, just add the following line to the configuration file:
      set historylog
      You can also use the switch below to save the history:
      -H or –historylog

    1. Use this option to not display the list of shortcuts at the bottom of the screen:
      set nohelp
      Runtime option:
      -x or --nohelp

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way


7 days a week, 24 hours a day