Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I often have multiple terminal windows opened with less (eg comparing various log files). I forget which file is which. Is there a similar command to ^G in vi which displays the name of the file currently being viewed?

share|improve this question
up vote 11 down vote accepted

Compatible: ^G. Easy to type: =. Less copied several key bindings from vi, including this one. This displays the file name (the path that you passed on the less command line) and the position in the file.

You can have this information permanently by calling less with the -M option. Include -M in the LESS environment variable. You can set this variable in your ~/.profile, ~/.pam_environment or wherever you define environment variables. Alternatively, you can set LESS by using lesskey to produce the configuration file ~/.less which is read by less.

share|improve this answer
Note that if you use less +F -M <filename> it won't show the filename until you quit the follow. (+F = --follow-name) – phyatt Jan 13 at 20:13
Awesome answer — I did not know about lesskey or about the -M option! – Noah Sussman May 27 at 7:07

I just found -M (show more verbose status line), which seems to do what I want.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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