Is there a way to tell nano to automatically show line numbering each time I open a file?

  • 4
    set linenumbers in nanorc does the trick – somethingSomething Jul 21 '18 at 11:26
  • CTRL+3 then SHIFT+3 will show line numbers CTRL+3 then SHIFT+3 will hide the line numbers – AATHITH RAJENDRAN Sep 28 at 5:10
  • Starting from nano 2.7.1 you can open file with -l (--linenumbers) flag to display lilne numbers beside the text. – Mikhail Oct 9 at 9:31

The keyboard combination to display the current line number whilst you are using nano is CTRL+C.

Alternatively, to display the line & column number position you could just use the -c parameter when launching nano i.e:

nano -c [filename]

To make this permanent, nano uses a configuration in your home folder ~/.nanorc

Thus to display line numbers always when using nano...

nano ~/.nanorc

(don't worry if its empty - this file doesn't exist by default)

type set constantshow

N.B. the deprecated syntax set const is shown in the animation


enter image description here


Since you are using line numbers remember you can use ALT+G to jump to a specific line number.

  • If you are in a tty, an alternative to CTRL+C is F11 and an alternative to ALT+G is F13 (which doesn't exist on my keyboard) or Ctrl+_ (Ctrl+Shift+-). – Radu Rădeanu Jun 3 '14 at 12:15
  • 8
    Note that -c might not behave the way people are expecting. It won't prefix each line with the number (like less -N), it just makes the status box at the bottom of the screen permanent. – Ian Dunn Sep 5 '16 at 18:03
  • I agree with @IanDunn, this is the wrong answer. Add set linenumbers instead (only works in recent versions). – xjcl Sep 17 at 15:35

Accidentally found nice shortcut: Alt + Shift + 3.

click me gently

  • 3
    doesnt work for me on ubuntu16.04 with GNU nano 2.5.3 – philx_x Oct 11 '17 at 12:09
  • 1
    does not work with mac keyboard on ssh'd ubuntu terminal – Dirk Schumacher Nov 8 '17 at 8:40
  • 7
    Add set linenumbers to .nanorc to make it permanent. If the shortcut doesn't work try Modifier key + #. – Chupo_cro Mar 16 '18 at 14:35
  • It works on Raspbian – dstonek Apr 7 '18 at 19:50
  • @Gregor Godier Thanks alot this is great with set linenumbers in nanorc – somethingSomething Jul 21 '18 at 5:51

Compile Nano from source:

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

Then add the following to your .nanorc file:

set linenumbers

You can use Meta+# to turn line numbers on and off from within Nano.

  • Actually like that. See you did 2 commits, was the 2nd one, (size increase..) because of the 1st one? – doug Jul 4 '16 at 23:10
  • Yes, that was because of the first one. – faissaloo Jul 5 '16 at 17:42
  • 1
    Sweet. I've submitted a request to merge this into nano at nano's savannah page: savannah.gnu.org/bugs/index.php?49217 – Max Burns Sep 28 '16 at 18:54
  • 1
    Which was and may still be correct when it comes to Ubuntu – faissaloo Jul 22 '18 at 15:23
  • 2
    In my case, set linenumbers is enough, without recompiling nano from source – realtebo Apr 9 at 10:37

If nano -c filename does not work, use nano filename then Ctrl +_. It will ask you for the line number to go to.

  • 1
    I'm using SSH and that keyboard shortcut makes the text smaller :( – kurdtpage Jun 21 '18 at 22:08

If you have already opened the file with nano you press


(not simultaneusly, press control and w, then without letting go control and letting go w, press t)

This command will require column and line, you enter them this way:

10,23 (enter)

and you will end up in line 10 character 23.

If you are at the top of the file and you only want to find the line:

Ctrl+w+t and then 10

If you are at a acertain line and you want to find the column:

Ctrl+w+t and then ,23

If you haven't opened the file yet, you can do this:

nano +10,23 file (enter)

and the file will open with cursor in the line 10, chanracter 23, so you can try also:

nano +10 file (enter)

nano +,23 file (enter) (Note that this will send you to the character 23 of the first line only)

  • This may be the correct way to find the line in the terminal however it does not answer the question on how to make it automatically show on opening. – DnrDevil Jan 27 '16 at 21:10
  • This is the only thing that worked for me to find a line number....none of the above worked in my instance of nano. – Uncle Iroh Feb 15 '17 at 17:08
  • Same as Ctrl+G? – Sanctus Oct 10 at 17:32

protected by Community Mar 9 '18 at 11:33

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.