How to Install and Use Nano Text Editor Commands in Linux?

Photo of author

By admin

The command-line tool is the most basic requirement for editing files on a Linux system. Text editors are also used most of the time to create new files. The most powerful Linux editors are Vim and Emacs, but these editors are complex and not suitable for beginners. There is, however, a simple text editor for novice users called GNU nano. Nano is a command-line text editor that you can use on your Linux and Unix computers. The text editor has all the necessary features, such as syntax highlighting, search and replace of expressions, spell checking, UTF-8 encoding, etc. By using the Nano text editor, you can edit or create files effortlessly on your Linux system. The following post shows a basic introduction to Nano—how to create and edit files with Nano and do a lot more in between, as well as how to install Nano. Check out the post and learn some basic commands for How to Install and Manage Nano Text Editor Commands in Linux.

The Installation Method of Nano Text Editor-

Generally, Nano comes by default in most Linux systems but if your system does not have it, you can install it manually. Depending on your operating system, the Nano text editor is already present on your computer. So, before you try to install it, apply a simple command: nano –version with your macOS or Linux distros command line. If the output shows you the version number of the Nano text editor, you won’t have to install it all over. You can skip the installation section and follow the other commands. Generally, the output will be this when you check if the Nano is present on your system or not:

GNU nano, version 2.9.3

(C) 1999-2011, 2013-2018 Free Software Foundation, Inc.

(C) 2014-2018 the contributors to nano

Email: Web:

If Nano is not present on your computer, you can install it with the following commands:

  • To install Nano on Ubuntu and Debian run: sudo apt install nano
  • To install it on CentOS and Fedora, run this: sudo yum install nano.

However, before you install Nano, there is one more task you should do. You need to open your terminal and update the apt repositories using the following command:

sudo apt update

Once you update the apt repositories, you can successfully install Nano with the previous command according to your operating system. Once you install the editor, you can easily generate and write files with it. Let’s check out how to do it.

How to Use a Nano Text Editor?

Let’s now learn how to open, organise, and write files with the Nano text editor. Additionally, we will show you how to examine and reconstruct texts using the editor. Nano can be opened and closed using nano filename. If the file name is demo.txt, you will use the nano demo.txt command. It is just an example of the file we showed you and you can open any type of file, including .txt, .html, etc. If you want to open a certain file, you need to access the directory where the file resides. If you are in a different location and want to access the file in /path/to/directory, you will use the command nano /path/to/directory/demo.txt.

However, if the file you are trying to open does not exist, then nano will create a new file. The file will be empty and untitled. If you want to start the text editor without trying to open a specific file, you can open the terminal by pressing Ctrl+Alt+T together on your keyboard. Then you can create a new empty nano file on the terminal using <strong>nano</strong>.

If you try to exit the window, it will ask you to discard it or save the file. You can press Y and then name the file and press Enter to finally save the file.

Edit the existing files: Nano is a graphical user interface (GUI) where you can easily edit and replace texts. So, if you try to edit a file, you can do that directly on the screen without much effort.

  • You can write and change the file and its content from the editor itself.
  • If you want to select a text, go to the beginning of the text line and press ALT + A and when you move the arrow, the text will be selected.
  • And then if you need you may copy that selected text with ALT + 6. Press CTRL + K to move the selected text and place it somewhere else with CTRL + U.

See, in Nano, everything is done with a stroke of a few keys. So, to know what keys work for what purpose, follow the next section.

Control Characters and Keys in Nano Editor

When you are working with the nano text editors, it is helpful to keep track of the control characters and keys that will help you navigate through texts effortlessly. You can use keyboard shortcuts and arrow keys to edit and change files with nano editor. Given below are some of the keyboard shortcuts that help you navigate through files in nano:

  • move forward one character: Ctrl+F (^F)
  • move back one character: Ctrl+B (^B)
  • move forward one word: Ctrl+Space (^Space)
  • move back one word: Alt+Space (M-Space)
  • move to the previous line: Ctrl+P (^P)
  • move to the next line: Ctrl+N (^N)
  • move to the next page: Ctrl+V (^V)
  • move to the previous page: Ctrl+Y (^Y)
  • move to the beginning of the line: Ctrl+A (^A)
  • move to the end of the line: Ctrl+E (^E)

Another thing worth noting is that you can press Ctrl+X or ^X to close the nano editor and the Ctrl+O (^O) combination will save the file before you close the editor. If you want to check the spelling of your texts on your nano editor, do it with Ctrl+T (^T). But for that, you will have to install the spell check feature with the sudo apt install spell command. Other things, you can do with the keyboard shortcuts as mentioned above.


As said already, when it comes to editing and creating text files, there is no other easy way to do that than using the nano text editor. If you are using Linux, all you have to do is apply some commands. All the features and functions in nano such as copying, pasting, selecting, searching texts are done by the keyboard shortcuts.

To recap, use ALT + 6

To copy a text. Use CTRL + U to paste the text.

The ALT + A key combination will select the text

The CTRL + W key combination will help you search in the text.

Nano is for all no matter whether you are a novice or a seasoned Linux user. With all the commands we have shown in this guide, you can easily modify files in the nano text editors. In case you need any help with the same, don’t hesitate to ask us in the comment section below.

Leave a Comment