I am looking for a keyboard shortcut to show the line numbers in nano editor when navigating up and and down within the file.

I have seen in multiple posts about CTRL+C but this doesn't automatically refresh the line number while navigating.

I remember that in the past I have used such shortcut in Linux terminal and if I recall it was for nano. I also think that it worked out of the box, I didn't have to change any parameters like this article shows: https://askubuntu.com/questions/73444/how-to-show-line-numbering-in-nano-when-opening-a-file

Is there any shortcut to do this? I have Ubuntu 16.04 and GNU nano 2.5.3.

3 Answers 3


You can enable and disable the lines number for each individual line instead through:

ALT + #

see the help (Open nano then type Ctrl + G ):

M-#             Line numbering enable/disable

Note that you can also enable line-numbering from the command-line too, using the argument -l, for example:

$ nano -l somefile.txt
  • 3
    It might be worth pointing out that this numbers each individual line, rather than constantly displaying the position at the bottom of the screen (as done temporarily by Ctrl+C). Commented May 9, 2018 at 17:45

Nano's default options are set in the config file /etc/nanorc so you can configure it to show line numbers by default on all files by uncommenting the "# set linenumbers" option, or run this from your terminal:

sed -i 's/# set linenumbers/set linenumbers/g' /etc/nanorc

You can use the -l or --linenumbers flags. So,

nano -l yourfile.txt

To make it permanent, uncomment set linenumbers in /home/<username>/.nanorc or /etc/nanorc

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .