Scroll to top

Nano is a text editor for the command line that is included in the default installation of nearly all Linux distributions. Compared to other command line text editors like vi/vim and emacs, it is easier to use, which is one of the main reasons newbies frequently choose it. It comes equipped with various helpful features such as syntax coloring, line numbering, a simple search interface, and many other options. This article will explain everything you need to know about the Nano command.

Let’s get started!

Install the Nano Editor on your Linux system

If Nano is not yet installed on your Linux system, you should be able to install it using the commands that are listed below:

  • apt install nano [For Ubuntu/Debian]
  • yum install Nano [For CentOS/Fedora]

Shortcuts for the Nano Keyboard

In order to perform its various features, such as finding text within a file or justifying text, the Nano command uses keyboard combinations. These combinations can be accessed very quickly and are shown for your reference as you work on the file. They adjust themselves mechanically in response to the actions you are now performing.

You should realize that a keyboard shortcut is indicated with and a symbol (^W) which is a combo of the Ctrl key and that symbol. This is something you should keep in mind when using keyboard shortcuts.

When a combination is displayed, to begin with, the letter M indicates that it needs to be finished by pressing the Alt key and the sign that comes next.

The following is a list of the available choices that will appear when you first open the Nano command:

  • G Get Help
  • ^O Write Out
  • ^W Where Is
  • ^ K Cut Text
  • ^J Justify
  • ^ C Cur Pos
  • M-U Undo
  • ^X Exit
  • ^R Read File
  • ^\ Replace
  • ^ U Uncut Text
  • ^ T To Spell
  • ^_ Go To Line
  • M-E Redo

It is optional for you to recall each option because they are constantly in front of you. You can activate Nano’s command help menu by hitting G (or typing F1), giving you access to the complete list of keyboard combinations. You will discover that specific keyboard shortcuts can be activated with a single key.

For instance, press the F1 key to get help and then press the F2 key to exit the nano command.

Launch Nano and create a new file

Creating a new file is simple as running


$ Nano

This will open the editor, and when you go to save the file, it will request that you give it a name so that it may save the new file under that name.

Open the Nano file browser

To open a file, you can run:

  • $ nano /my text file.txt 

The above command will attempt to open the “my text file.txt” file located in your home directory. The nano command will attempt to create the file if it does not already exist. You’ll need to open a file and navigate to a certain line or column at some point. This is something that can be accomplished using the following Nano command:

  • $ nano +line,columns file

Using the Nano command to Perform Edits on Files

When you open files or create new ones, you can immediately edit or write in them. In Nano, as opposed to vim, there is no requirement to transition into edit mode. You can navigate the file by using the arrow keys on your keyboard to move the cursor in the appropriate direction.

Try Looking for Some Text in Nano

The “where is” option, which is represented by the key combination W, enables you to search for text included within a file. This will cause an input for searching to appear above the menu.

You will also notice that the bottom menu will change and display some new options when the update has been applied. They explain themselves, but we will go over the most significant ones.

Copy/Paste/Cut Text in Nano

Nano’s user interface is quite familiar to anyone who has used a graphical editor. To copy or cut text in a GUI editor, you must first choose the text you intend to work with. It’s the same deal with Nano. Press Ctrl + ^, then use the arrow keys to select different parts of the text.

  • To copy the marked text, press Alt + ^.
  • To cut the marked text, press ^K (Ctrl +K)

Once you’ve found a good spot for the cursor, press ^U (Ctrl + U) to paste the highlighted text.

Save File in Nano

If you want to save the modifications you’ve made to the file, you can press the ^O (Ctrl + O) combination.   You will be prompted to give a name to a new file whenever you edit one of those files for the first time. This will save the changes you have made so far, and Nano will remain open, so you may keep modifying the file.

Exit Nano Editor

To exit Nano, press ^X (Ctrl +X keys). If the project has yet to be saved, you will be asked if you want to save the changes by selecting yes or no or whether you want to cancel the exit.

Nano is a fantastic command line text editor that is straightforward to operate and appealing to users due to its ease of use. Because its user interface is comparable to that of GUI editors, it is an excellent choice for people who are new to Linux.

Post a Comment

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