In Linux, working through the terminal is often the most efficient way to manage systems, view logs, or interact with files. One command that every user — beginner or experienced — should know is less. The less command is a terminal pager used to view the content of text files one screen at a time. It’s especially useful when you need to read large files or outputs from other commands without overwhelming your screen.

What Does less Do?

When you open a file with less, it doesn’t load the entire file into memory. Instead, it streams the content as you scroll, which makes it very fast and lightweight — even with log files that are several megabytes in size. Unlike text editors like nano or vim, less is non-editable — it’s strictly for reading. This means you can safely open configuration files, logs, or any text file without the risk of accidentally modifying them.

Syntax and Basic Usage

less [options] filename

Example:

less /var/log/auth.log

This will open the system authentication log in less, allowing you to navigate through it with simple key commands.

Key Navigation Commands in less

KeyFunction
SpaceScroll forward one page
bScroll backward one page
EnterScroll down one line
gGo to the beginning of the file
GJump to the end of the file
/patternSearch forward for a keyword (e.g. /error)
n / NRepeat search (next/previous match)
qExit less

These commands make it easy to review logs, search for specific entries, or simply browse through structured files.

Practical Examples

Example 1: View a large configuration file

less /etc/ssh/sshd_config

Quickly check SSH settings without accidentally changing anything.

Example 2: View system logs with search

less /var/log/syslog

Then press /fail to search for lines containing “fail”.

Example 3: Use less with another command

ps aux | less

View the full output of the ps aux command without it scrolling off the screen.

Options Worth Knowing

  • -N — Show line numbers:

    less -N /etc/passwd
  • -S — Chop long lines instead of wrapping them:

    less -S /var/log/dpkg.log
  • +G — Open file and jump straight to the end:

    less +G /var/log/mysql/error.log

These options enhance how you interact with files in various contexts — from debugging errors to verifying recent log entries.

Extra Tip: Work with Compressed Files

You can read .gz files without extracting them using zless, a variation of less:

zless /var/log/syslog.1.gz

It behaves exactly like less, but works with compressed content — ideal for archived logs.

Summary

The less command is one of the simplest yet most practical tools in any Linux user’s toolkit. Whether you’re managing a VPS, analyzing logs, or just navigating through system files, less helps you read comfortably, safely, and efficiently. It doesn’t edit files, doesn’t consume extra memory, and gives you full control over how you view data — one page at a time.