If you've ever loaded a 40,000-line log file into your terminal and watched it choke while trying to display the entire file all at once, then the less command in Linux is something you'll want to use. less loads only enough of the file to fit on your screen, waits until you're ready, and allows you to scroll at your own pace.
When I first had to read the logs of my production Nginx server during an outage, I used cat out of habit because it felt easier than using less. However, thousands of lines flew past my eyes within seconds, the single error message I needed scrolled right off the top of my terminal window, and I wasted a minute I did not have. Using less would have allowed me to slowly page through each entry and search for the specific status code I was looking for.
This tutorial is for anyone, whether you are a complete beginner or an experienced administrator who wants to read files in the terminal without frustration. By the end, you will be able to navigate, search, and follow files easily, as if it were second nature.
Tip:
If you are still finding your footing in the shell, keep our basic Linux commands reference open in another tab while you work through these examples.
Examples
What Is the less Command in Linux?
less is a pager. It shows a file one screen at a time so you can read it instead of watching it scroll past in a blur.
Under the hood it does not load the entire file into memory before showing you anything, which is why it opens a multi-gigabyte log almost instantly while a plain dump would stall. You move forward, jump back, search, and quit, all without a text editor and without changing a single byte of the file. If you already read files with cat, think of less as the calmer sibling you use the moment a file is too big to fit on one screen.
less Command Syntax
LinuxTeck.com
less [options] filename
# Open a single file
less /var/log/syslog
# Read the output of another command
ps aux | less
The pieces are simple. options are flags that change behaviour, like turning on line numbers. filename is whatever you want to read. The pipe form matters just as much in real work: any command that prints a lot of text can be sent straight into less so it does not flood your screen.
Note:
By default, less does not automatically exit when you reach the end of a file. It will display (END) at the bottom of the screen and wait for you to navigate backward or press q to quit.
Common less Options You Will Actually Use
| Option | What It Does | When to Use It |
|---|---|---|
| -N | Shows line numbers down the left side | Reading config files or code where line position matters |
| -i | Makes searches ignore case | Hunting for "error" when logs mix Error, ERROR, error |
| -S | Stops long lines wrapping, lets you scroll right instead | Wide CSV files or JSON logs that turn into mush when wrapped |
| +F | Follows a file as it grows, like tail -f | Watching a live log during a deploy or an outage |
| +G | Jumps straight to the end of the file on open | Logs, where the newest entries are what you care about |
| -X | Leaves the file content on screen after you quit | When you want the last view to stay in your scrollback |
less Command Examples
I. Open a File and Scroll Through It
The simplest use. Point less at a file and read. Press Space to go down a page, b to go back, and q to quit.
LinuxTeck.com
less /etc/ssh/sshd_config
Include /etc/ssh/sshd_config.d/*.conf
Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
:
Tip:
The colon at the bottom is the less prompt. It means less is ready for your next key, not that something broke.
II. Show Line Numbers
When you are reading a config and a service complains about "syntax error on line 88", numbers save you from counting by hand.
LinuxTeck.com
less -N /etc/nginx/nginx.conf
2 worker_processes auto;
3 pid /run/nginx.pid;
4 include /etc/nginx/modules-enabled/*.conf;
5
6 events {
7 worker_connections 768;
8 }
:
III. Search for a Word Inside the File
Once less is open, type / followed by your search term and press Enter. Press n to jump to the next match, N to go back.
LinuxTeck.com
less /var/log/auth.log
May 30 09:14:05 web01 sshd[2293]: Failed password for root from 203.0.113.7 port 51246 ssh2
/Failed
IV. Jump to the Start or End Fast
Inside less, press G to leap to the end of the file and g to fly back to the top. No scrolling required.
LinuxTeck.com
less /var/log/syslog
May 30 11:03:10 web01 CRON[4410]: (root) CMD (/usr/local/bin/backup.sh)
(END)
V. Search Without Worrying About Case
Logs are inconsistent. One service writes "Error", another "ERROR". The -i flag makes your search catch all of them.
LinuxTeck.com
less -i /var/log/syslog
May 30 10:42:00 web01 app[8123]: ERROR could not connect to database
/error
VI. Stop Long Lines From Wrapping
Wide JSON logs and CSV files wrap into an unreadable wall. The -S flag keeps each record on one line so you scroll right with the arrow keys instead.
LinuxTeck.com
less -S access.log
198.51.100.9 - - [30/May/2026:09:01:23 +0000] "POST /api/v1/checkout HTTP/1.1" 500 812 "-" "curl/8.5.0" >
:
VII. Pipe Another Command Into less
Any command that spews more than a screenful is a candidate. Send it through a pipe and read it instead of scrolling your terminal back up.
LinuxTeck.com
ps aux | less
root 1 0.0 0.1 168320 11200 ? Ss 08:55 0:02 /sbin/init
root 412 0.0 0.2 234112 18044 ? Ss 08:55 0:00 /usr/lib/systemd/systemd-journald
www-data 8123 1.2 3.4 998120 68200 ? Sl 09:01 0:14 /usr/bin/python3 app.py
:
Note:
If you do this kind of filtering a lot, our roundup of Linux text processing commands pairs well with less for shaping output before you read it.
VIII. Open Straight at the End of a Log
When you only care about the newest entries, +G drops you at the bottom the moment the file opens.
LinuxTeck.com
less +G /var/log/syslog
May 30 11:59:01 web01 systemd[1]: Reloaded nginx.service
(END)
IX. Follow a Live Log While It Grows
This is the real world scenario. A deploy is running, the log is still being written, and you want to watch it live. Use +F. To stop following, press Ctrl+C, then keep paging normally. Press Shift+F again to resume.
LinuxTeck.com
less +F /var/log/nginx/error.log
2026/05/30 12:03:14 [warn] 9921#0: *4413 client closed connection while waiting
Waiting for data... (interrupt to abort)
Tip:
+F gives you something tail -f cannot: hit Ctrl+C and you can scroll back through everything already loaded, then press Shift+F to start following again. It is the best of both worlds when you are chasing live errors. For more on reading logs cleanly, see our notes on Linux logging best practices.
X. Open Several Files and Switch Between Them
Give less more than one file and it loads them as a set. Inside, type :n for the next file and :p for the previous one.
LinuxTeck.com
less syslog auth.log kern.log
...
auth.log (file 2 of 3)
:
XI. Read a Compressed Log Without Unzipping It
Rotated logs often end in .gz. You do not have to decompress them first. zless reads them in place.
LinuxTeck.com
zless /var/log/syslog.2.gz
May 28 00:05:12 web01 CRON[3001]: (root) CMD (/usr/local/bin/backup.sh)
:
XII. The Mistake: Reaching for cat on a Huge File
This is the habit that bit me. Dumping a giant file with cat floods your terminal, the line you wanted scrolls away, and on a slow connection it can hang for ages.
LinuxTeck.com
cat /var/log/syslog
# Right: page through it calmly and search inside
less /var/log/syslog
Warning:
cat is fine for tiny files. On a large log it prints everything to your scrollback at once, the line you needed disappears off the top, and you cannot search within it. Reach for less the moment a file is bigger than your screen.
Why less Matters in Real Work
When something breaks on a production box, you are reading files, not editing them. less lets you open a multi-gigabyte log instantly, jump to the end, and search for the error code while the clock is ticking. That speed is the difference between a calm fix and a panicked one.
It is also the safest way to inspect a file. You cannot accidentally change a config in less the way you can fumble it open in an editor, which matters a lot when you are touching shared servers. The behaviour is documented in detail in the official less man page, and once it lives in your fingers you stop thinking about it and just read.
Key Takeaways
- Press q to quit, Space and b to move a page at a time, and g or G to snap to the top or bottom instantly.
- Type /word inside less to search forward, then n for the next match and N for the previous one.
- Add -i so a single search catches Error, ERROR, and error without three separate tries.
- Use -S on wide logs and CSVs so long lines stop wrapping and you scroll right instead.
- Open logs with +G to land on the newest entries, or +F to follow the file live like tail -f.
- Pipe any noisy command into less with the | operator instead of letting it flood your terminal.
- Reach for zless on rotated .gz logs so you never have to unzip them just to read a few lines.
Questions I Get Asked About This All the Time
I opened a file with less, how do I actually get out of it?
Press q. That single key quits less and drops you back at your shell prompt. If you ever feel stuck, q is almost always the way out.
The arrow keys are not scrolling for me, what am I doing wrong?
Certain remote SSH sessions or custom terminal emulators don't map arrow key escape sequences correctly. Use the reliable vim style keys instead: j moves down one line, k moves up, Space jumps a full page down, and b jumps a page back. Those work everywhere.
How do I find a word once I am already inside the file?
Type a forward slash, then your word, then Enter, like /timeout. less jumps to the first match. Press n to go to the next one and N to step backward. Add -i when you open the file if you do not want case to matter.
My log keeps growing while I read it, can less keep up?
Yes. Open it with less +F, or press a capital F once you are inside, and it follows new lines as they land. Hit Ctrl+C to stop following and scroll back through what you have, then press Shift+F again to resume.
less is wrapping long lines into a mess, how do I stop that?
Quit, then reopen with less -S. Long lines now stay on one line and you scroll sideways with the right and left arrow keys. This is a lifesaver on wide access logs and CSV files.
Why bother with less when cat already shows me the file?
cat dumps everything at once, which is fine for a short file and painful for a long one. less shows one screen at a time, lets you search inside, jumps around, and never floods your terminal. For anything bigger than your screen, less is the better default.
From your first terminal command to advanced sysadmin skills every guide here is written in plain English with real examples you can run right now.