Nano Text Editor in Linux

Nano is a user-friendly, simple and WYSIWYG(What You See Is What You Get) text editor, which improves the features and user-friendliness of UW Pico text editor. Unlike vim editor or any other command-line editor, it doesn’t have any mode. It has an easy GUI(Graphical User Interface) which allows users to interact directly with the text in spite of switching between the modes as in vim editor.

Installing Nano Text Editor

Nano is generally by default available in many Linux distributions but in case, it is not installed you may install the same using the following commands.

$sudo apt update

In case of Debian/Ubuntu

$sudo apt install nano

In case of CentOS/Fedora

$yum install nano

Working with Nano Text Editor

1. To create and open a new file.

$nano new_filename

creating and opening a new file in nano text editor

The above command will open a new file with new_filename as shown in the output. In case the file already exists it will open the same and in case the file is not there in the current directory it will create a new one. At the bottom of the window, there is a list of shortcut keys for nano.

2. To save a file

press Ctrl+o

It will ask you for the filename. In case, you want to save the changes to a new file or want to create a new file then change the name else keep the name same.

saving a text file in nano text editor

As soon as you will press enter key, then In case, you have changed the name of the file then it will save the file with a new name and if not then it will save the changes to the current file.

3. To cut paste in a file. Ctrl+o is used to cut and Ctrl+u is used to paste the text.