How To Efficiently Use Nano Text Editor In Ubuntu Linux OS

Posted on September 14th, 2022

No matter which operating system we are using, editing a text file is one of the most crucial actions which we perform on a daily basis. In Windows, we have Microsoft Word as a default text editor, if not Microsoft Word then, we use Notepad for editing a simple text file. 

But in the case of Linux OS other popular text editors like Microsoft Word, and notepad are not available.

In this blog post, we will learn about text editors available in the Linux operating system. Also, we will cover in detail one specific text editor called Nano text editor. 

We will perform the practicals right from how you can create a text file by using in a nano text editor, to how you can save and perform multiple actions by using the nano text editor.

So make sure you read the complete blog and understand how easy it is to use the nano editor.

The command line interface of Linux is used by most engineers to create a script, to write a code, or make changes in the existing configuration file. Every now and then to make changes in the text file we have to open it with a text editor. 

I have already covered what text editors are. Let me give you the various text editors available in the Linux operating system. Some text editors may be available by default on Linux and for some, you might have to install them with the commands.

List of text editors available in Linux operating system

  1. Vi 
  2. Vim
  3. Gedit
  4. Nano
  5. Atom text editor
  6. Sublime text editor

There are other text editors as well which are available, but most of the time vi/ vim, gedit, and Nano text editors are taken into consideration for making any changes in a text file.

Out of all the text, editors mentioned Nano text editor is my favorite one. Not just because of its name but because it is very easy to use and the commands for using Nano text editor are very simple.

The nano text editor is installed by default in your Linux operating system, but let’s say it  is not installed then what you need to do is mentioned below.

If the nano text editor is not installed by default then you need to update your apt package manager. Execute the following commands to update repositories and install nano editor.

$ apt update -y && apt install -y nano

With this command, Nano text editor will be installed on your Linux operating system.

How To Create A Text File Using Nano Text Editor

To create a file by using the nano text editor you have to follow the given syntax.

Syntax – nano nameoftextfile

Example – $ sudo nano sample

Here we have created a text file with help of the Nano text editor. The name of a text file is sample. 

As soon as you enter a pop-up of the nano text editor will appear. You can start typing in the text editor whatever you want to type.

1. Save and exit a text file by using the nano text editor

Let’s say you have made all the required changes and created this text file and now you what to save and exit the changes in the nano text editor. In this situation, use the following command.

Command – Ctrl + X

This command will ask you if you want to exit the nano text editor with or without changes. 

In this response, if you have to make changes to the text then, for save all the changes made press Y and enter (Keyboard). Now all the changes will be made to the text file.

2. Exit Nano Text Editor Without Saving Changes

If you have made any error and want to exit the nano text editor without saving any changes then use the below command.

Command – Ctrl + X

The Nano text editor will ask you if you want to exit with or without saving. 

in this case, we don’t have to save the changes made. So we press Ctrl + X and then N on the keyboard plus Enter button. 

That’s how you exit the nano text editor without making any changes.

3. Select A Line In Nano Text Editor

To select a line in a nano text editor, you can select it with the help of a mouse and cursor as well, but the smart way of selecting a line or multiple lines in a nano editor is by using the following keys

Command  – Shift key on the keyboard and the right arrow or left arrow key.

4. Delete a Line on Nano text Editor

To delete a line on a nano text editor, first, you need to point your cursor to that line. and later if you want to delete the entire line then you can give this command

Command – Ctrl+ K 

Or else if you want to delete a selected portion of a line thenyou then you first need to select the respective portion and then you need to use the use Ctrl + K.

5. Undo or Redo An Action in Nano Text Editor

Let’s say that you have committed a typing error and you want your text file as it was before, then you can use the following command for undo operation.

Command For Undo – Esc + U

If you want to redo an action in the nano text editor and you can use the below command.

Command For Redo –  Esc + R

6. Search In Nano Text File Editor

Let’s say the text file contains hundreds of lines of code and if you want to search for a specific word then what can you do on the nano text editor? 

Nano text editor is very smart and it has also provided a feature for this scenario.

Use the following command for searching a specific word on the nano text editor.

Command – Ctrl + W

Now, type what you have to search.


In this blog post, we have covered – Types types of note editors available in the Linux operating system. We have discussed in depth about nano text editor and performed practicals on the most used features in the nano text editor.

In the future, we will also cover the other text editors on this website. Iin case if you have any doubts please mention them in the comment section.

Leave a Reply