1. Home
  2. Linux
  3. How to use the nano text editor on linux

How to use the Nano text editor on Linux

There are many different text editors on Linux, and the community is quite passionate about this subject. However, one text editor stands out from the rest as the easiest to use, especially for beginners. That text editor is Nano.

Nano text editor on Linux

Nano comes pre-installed on quite a few Linux systems, and for a good reason. It has simple keybinds and is easy to pick up for editing configuration files. In this guide, we’ll show you how to use and install the Nano text editor.

Installing Nano on Linux

While it is true that Nano is pre-installed on a lot of mainstream Linux operating systems, it’s still good to go over how to install the software in case you’re on a Linux system that doesn’t have it. 

To start installing the Nano text editor on Linux, you must open up a terminal window. To open up a terminal window on the Linux desktop, press the Ctrl + Alt + T keyboard combination. Or, alternatively, search for “Terminal” in the app menu and open it up that way.

With the terminal window open and ready to use, follow along with the installation instructions for Nano that correspond with the Linux OS you currently use. 

Ubuntu

On Ubuntu, the Nano text editor comes pre-installed. However, if you do not have it on your system for some reason, you can quickly install it using the Apt command below.

sudo apt install nano

Debian

Debian Linux has the Nano text editor pre-installed. That said, if you’ve previously uninstalled it or do not have it installed out of the box, you can quickly set it up using the Apt-get command below.

sudo apt-get install nano

Arch Linux

The Nano text editor doesn’t come with Arch Linux, as users need to build their own operating system. As a result, the package must be manually set up on the system. To install Nano on Arch Linux, use the following Pacman command.

sudo pacman -S nano

Fedora

Fedora Linux doesn’t come pre-installed with Nano, as the developers choose to include other text editors in its place. However, the Fedora software repository has the Nano package, and it is quite easy to install using the Dnf command.

sudo dnf install nano

OpenSUSE

OpenSUSE Linux should come with Nano pre-installed and ready to use. That said, if you find yourself unable to open up Nano out of the box, you can quickly install it from the primary OpenSUSE Linux software sources using the Zypper command.

sudo zypper install nano

Snap package

The Nano text editor is available as a Snap package. So, if you find yourself on a Linux operating system that doesn’t have Nano readily available but supports Snaps, you will still be able to install it. 

To install the Snap version of Nano, you will need to set up the Snap runtime. You can get the Snap runtime up and running on your Linux PC by following this guide on the subject.

After setting up the Snap runtime on your computer, you can get the Nano text editor working via snap with the following snap install command.

sudo snap install nano

How to use the Nano text editor on Linux

The Nano text editor is a terminal-based application. As a result, you’ll only be able to use it in an active terminal window. To open up any file in Nano, use the nano command, followed by the path to the file you wish to edit.

For example, to edit test.txt in the home directory, you’d use the following command.

nano /home/USERNAME/test.txt

If you’d like to enable the use of the mouse in the Nano text editor, you can open up the test.txt file with the -m command-line switch. 

nano -m /home/USERNAME/test.txt

To use the auto-indent feature in Nano, the -i command-line switch can be used.

nano -i /home/USERNAME/test.txt

To edit a file without reading its contents, the -n command-line switch can be used. 

nano -n /home/USERNAME/test.txt

Many different command-line options and switches can be enabled to use the Nano text editor in interesting and useful ways. For more information on all of the switches, execute nano –help in a terminal window.

Cutting in Nano

You may want to cut text in the Nano text editor. Here’s how to do it. First, open up a file with the editor. Once it is open, use the directional arrows on the keyboard to move the cursor to where you wish to copy text.

Once the cursor is in place, hold down Shift and use the Left or Right arrow to highlight the text to cut. Then, press Ctrl + K to cut the text to your clipboard.

Pasting in Nano

To paste text in the Nano text editor, open up a file as you usually do. Once the file is open, press Ctrl + Shift + V on the keyboard. By pressing this, you’ll be able to paste text from your keyboard.

More info on Nano

In this guide, we went over the basic usage of the Nano text editor. If you’d like to learn more, look at the full manual. To do that, open up a terminal window and execute the man nano command.

man nano

Leave a Reply

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

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