less command

Updated 29 October 2024

bash
$ less <filename>
SPACE or CTRL+Fforward one window
b or CTRL+Bbackward one window
d or CTRL+Dforward half window
u CTRL+Ubackward half window
jnavigate forward by one line
10j10 lines forward.
knavigate backward by one line
10k10 lines backward.
Ggo to the end of the file
ggo to the start of the file
q or ZZexit the less pager
/search forward for a pattern
nmove forward for the next occurrence.
Nmove backward for the previous occurrence
?search backward for a pattern
nmove backward for the next occurrence.
Nmove forward for the previous occurrence

Other commands

FFollow the end of the file as more lines are added, similar to tail -f.
m<any-lower-letter>Mark the current position with the letter the specified lower letter,
‘<lower-letter>go to the marked position marked with the specified lower letter.
&patterndisplay only the matching lines, not all.
vOpen the current file in the default editor.
CTRL+G or =show the current file name along with line, byte, and percentage statistics.
hdisplay help
:e filenameWhile viewing a file with less this command allows you to open/examine a.
:ngo to the next file
:pgo to the previous file

Options

Spotted a mistake or want something added? Send me a note.