Special offer
+370 5 205 5502 sales@monovm.com

How to Display Line Numbers in Nano Editor?

Two of the most powerful and commonly used command-line editors are Vim and Emacs. When using the command line, it is normal to create and update text files. Both have a steep learning curve that new users can find intimidating. Nano is a simple editor for those who do not know how to use Vim or Emacs. Nano is the most simple text editor for Linux that is command-line based. It includes all of the usual text editor functionality, such as syntax highlighting, multiple buffers, search and replacements with regular expression support, typo correction, and UTF-8 encoding.

31 May, 21 by Antoniy Yushkevych 2 min Read

A Brief Tutorial on How to Show Line Numbers in Nano Editor


How to Display Line Numbers in Nano

There are three methods to display line number in nano, and they are as follows:

Method 1

You can directly use the following command to display line numbers in Nano:

 --linenumbers [filename]

In the above command, you need to write your file's name instead of [filename].

Method 2 

You can press  Alt and # or Alt, Shift, and 3 key combinations to display line numbers quickly.

Method 3

You can compile Nano from the scratch:

git clone git://git.savannah.gnu.org/nano.git;cd nano;./autogen.sh;./configure;sudo make install

Then, in your /.nanorc file, add the following:

# include all the preexisting configs

include "/usr/share/nano/*.nanorc"

set linenumbers



Using any of the three methods, you can easily set line numbers in your nano editor. Line numbers are important for users to get references on which line they are working on. Enabling them will help them understand and find an error in any of the lines.

Antoniy Yushkevych

Master of word when it comes to technology, internet and privacy. I'm also your usual guy that always aims for the best result and takes a skateboard to work. If you need me, you will find me at the office's Counter-Strike championships on Fridays or at a.yushkevych@monovm.com