How To Install And Work With Nano Text Editor In Linux?


Nano is a simple and user-friendly text editor mostly used on Unix like operating systems. It emulates the Pico text editor and provides additional features and functionalities. Unlike vim, it does not operate in different modes. In nano, the user directly interacts with the text.

This article describes how to install and use the nano text editor in Linux operating system.

How to install nano text editor in Linux

There are various distributions of Linux, each of them uses different methods to install or remove packages on them. Nano is available by default in various distributions if it is not in your system then use one of the given commands to install it –

To install nano in the Debian, Ubuntu, Linux mint, etc use –

sudo apt install nano

In Centos or RHEL use –

sudo yum install nano

If you are using Fedora use –

sudo dnf install nano

Working with the nano text editor

Creating, editing files in nano is much easier as compared to other command-line text editors available in Linux. Let us see how you can use the nano to create or edit text files.

Create a new file

To create a new file lets say file1, first open your terminal by pressing ctrl+alt+t and then use the following command –

nano file1

When you press the enter after typing this command this will open file1 for editing. You can start entering text here –

Copy, cut or paste text in the nano text editor

Press and hold the ctrl+shift and then move the cursor using the arrow keys to mark the text. And then –

  • Press the alt+6 for coping the marked text and then move the cursor where you want to paste it, press ctrl+u to paste the copied text.
  • If you want to cut the marked text press the ctrl+k. Now move the cursor where you want to paste it and press the ctrl+u to paste the text.

Search text

To search for the specific text in a file press ctrl+w this will display an option for search, As you can see in the image below. Enter the text that you want to search in this file and then press enter, this will bring the cursor to the starting of that word or pattern.

 Save the content of the file

To save the content of file1 press ctrl+s. This will save the content of the file under the file name file1. If you are saving text for the first time then it may ask you to enter the file name to write the text.

Save the content of a file with a different filename

You can change the file name while saving its content, Press ctrl+o this will give an option to edit the file name, change the name if you want and then press the enter to save it.

Or If no filename is provided till now then here you can enter the name of this file.

After entering the file name if you press enter, this will prompt you for confirmation, enter yes and then press the enter key to save it.

Exit from the editor

When you are done editing press ctrl+s to save and then press ctrl+x to exit from the editor.

Conclusion

By following the given steps you can start using the nano text editor in Linux. Now If you want to say something on this topic then write us in the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.