How to Install and Use Nano Text Editor on CentOS

YouTube video

In this tutorial, I’ll guide you on installing and using Nano text editor on your CentOS system. Text editors allow you to create and edit different files on your server using an SSH client without accessing your file system using an FTP client.

You may ask why am I mentioning an FTP client here? Basically, the CentOS system comes with a Vim text editor by default. I found Vim so tricky to use, and I applied a quick trick to edit the files without Vim. I used to access the file system using FileZilla and edit the file.

When I came to learn about Nano, I’m so excited as it’s easy to use like hell. I hope after you go through this tutorial, you will be able to use this fantastic text editor to do all your necessary file editing tasks on an SSH client, indeed.

However, If you need to upgrade or buy a new VPS, read how to set up the most affordable VPS. Also, I recommend Contabo as they provide the most affordable virtual machines with an exemplary configuration and service.

How to Install Nano Text Editor

Before we start the installation process, let’s check if your system already has it.

To check, run the following command:

which nano

If Nano text editor is installed, you will get an output like below:

/usr/bin/nano

If Nano text editor is installed, you will get an output like below:

/usr/bin/which: no nano in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)

If the output was the latter one, let’s get right to install it.

Run the following command:

yum install nano

After that, it will ask your permission to install the package and the public key. Type y and press enter for both of the cases.

How to Use Nano

The syntax to open a file with Nano is the following:

nano filename

For example, you want to open a file named test.txt; then the command should be the following:

nano test.txt

You can edit different file types, like .conf, .txt, .php, .html, etc. using the Nano text editor. Keep in mind that when opening any configuration file, you should put -w after the word nano. This will open the file in a standard format instead of wrapping the texts to fit the window.

The command to open a file with -w option should look like this:

nano -w /etc/httpd.conf

Opening and editing the configuration files without -w option may create malfunction of the configuration file, and your system may have boot failure.

Basic Commands of Nano Editor

You can see the necessary commands at the bottom of the window. The character ‘^’ means Ctrl for Windows and Control for Mac.

nano editor basic commands

Some other very basic commands are:

  • Cut – Ctrl + K
  • Paste – Shift + Insert
  • Saving the changes – Ctrl + O
  • Exit nano – Ctrl + X

Certainly, nano text editor and learning it’s basic commands will help you much to entertain your all text editing needs with SSH very easily.

If your system doesn’t have a swap partition space created, you can easily create a swap partition to improve your system stability in stressful conditions. Also, you can use your nano editor for the first time there ;).

Was the tutorial helpful? Click to rate it!
5 vote(s), avg: 5 out of 5

Leave a Comment