Skip to main content

Command Palette

Search for a command to run...

More people should use `less`

Updated
4 min read
More people should use `less`

In the world of Linux command-line tools, there’s an old joke: “Why should more people use less? Because less is more!” This pun isn’t just a play on words—it’s a nod to one of the most underrated utilities in a sysadmin or developer’s toolkit. While many users default to commands like cat or more to view files, the humble less command offers a superior experience for reading, navigating, and analyzing text. Let’s dive into why less deserves a prime spot in your workflow.

What is less?

less is a terminal pager designed to view and navigate through files or command output efficiently. Introduced in 1984 as a successor to more, it earned its name because it does “more” by requiring “less” effort (and because, unlike more, it allows backward movement in files). While more was limited to forward-only scrolling, less broke boundaries by enabling bidirectional navigation, robust searching, and seamless handling of massive files.

Key features of less

  1. Scroll Freely, Forward and Backward
    With less, you’re not stuck moving in one direction. Use the arrow keys (or vim motion keys if you prefer), Page Up/Page Down (or f and b like vim again), or even the spacebar to scroll. Want to jump to the end? Press G. Return to the top? Press g.

  2. Search Like a Pro
    Tap / to start a forward search or ? for a backward search. less highlights matches and lets you cycle through them with n (next match) or N (previous match).

  3. Handle Massive Files with Ease
    Unlike text editors that load entire files into memory, less opens files incrementally. This makes it perfect for log files that are gigabytes in size—no freezing or lag.

  4. Follow Real-Time Updates
    Watching a growing log file? Press F to enter “follow mode,” and less will tail the file in real time, similar to tail -f. Exit follow mode with Ctrl+C.

  5. Line Numbers and Wrapping
    Toggle line numbers with -N (e.g., less -N file.txt or type -N after opening the file) or disable line wrapping with -S to avoid messy output.

  6. Show colors from your logs

    If you open a file with colored strings, then you can show those colors using the -R option.

  7. Integrate with Pipelines
    Pipe output from commands like grep, awk, or journalctl directly into less for easier analysis:

     grep "ERROR" app.log | less
    

Why ditch more for less?

The original more command is still around, but it lacks many of less’s features. For example:

  • No backward scrolling: Once you scroll past a page in more, you can’t go back.

  • Limited navigation: more lacks search highlights, jump-to-end shortcuts, or follow mode.

  • Basic functionality: It’s just… less.

Even the manual page for more admits its shortcomings, often stating, “more has fewer features than less.”

Getting started with less

Most Linux and macOS systems include less by default.

But, in case you don’t have it readily installed it is usually available in your OS’s package manager. In Ubuntu, you can run this to install less

sudo apt install less

To open a file:

less filename.txt

Essential Commands:

  • q: Quit.

  • /pattern: Search for “pattern.”

  • :n and :p: Navigate between multiple files (if opened with less file1 file2).

  • -i: Ignore case in searches (use less -i file).

  • v: Open the file in your default text editor (e.g., Vim).

Advanced tips

  • View Compressed Files
    Use less with tools like zless to view compressed files without manual extraction.

  • Customize Display
    Set environment variables in your shell config (e.g., ~/.bashrc) to tweak less’s behavior. For example:

      export LESS="-i -N -S -R"
    

    This ignores case in searches, enables line numbers, chops long lines, and shows colors.

  • Avoid Binary Files
    If you accidentally open a binary, less will warn you. Press q to exit, then use tools like strings or xxd instead.

Conclusion

In an era of bloated GUIs, less remains a lightweight, powerful tool for anyone working in the terminal. Its versatility, speed, and intuitive navigation make it indispensable for debugging logs, reading documentation, or exploring data. So next time you reflexively type cat or more, give less a try. After all, why settle for “more” when you can have… less?

Pro Tip: Type man less to view its manual—ironically, you’ll be reading it in less itself. Now that’s meta!