less
- to browse a file one page at a time
There are many commands you can use when browing a file using less
. You can always use less --help
to view these commands.
Syntax
Description
Option |
Description |
-n -N –line-numbers |
show line number |
–help |
display help |
Moving Command |
Description |
j |
next line |
k |
prev line |
G |
last line |
g |
first line |
f, ^F, SPACE |
forward one window (or N lines) |
b, ^B |
backward one window (or N lines). |
d |
scroll forward N lines, default one half of the screen size |
b |
scroll backward N lines, default one window |
u |
scroll back N lines, default one half of the screen size. |
Search Command |
Description |
/pattern |
Search forward in the file for the N-th line containing the pattern. N defaults to 1. |
?pattern |
search backward in the file for the pattern |
Example
Browse a file
browse /etc/passwd, which contains all the user info.
Browse /var/log/syslog. Use -N
option to show Line number.
1
| sudo less -N /var/log/syslog
|
show process info using less
Reference