Linux for Developers Course
Linux for Developers
/
Beginner

less

Definition

A terminal pager program used to view the contents of a text file one screen at a time. It is the safe alternative to `cat` for reading large files.

Explain Like I'm New

Reading a book one page at a time. Instead of dumping all the text, it fills your screen, pauses, and lets you use the arrow keys to scroll down at your own pace.

Real World Example

You need to read a massive server log. You type `less server.log`. You can easily scroll up and down, and even type `/error` to search the document for specific words.

Common Use Cases

  • •Reading large logs
  • •Searching inside text files safely

Interview Questions

basic

  • How do you exit the `less` program when you are done reading?

intermediate

  • Why does `less` load massive files so much faster than text editors like Vim or Nano?

Flash Cards

Question

How to exit?

Click to reveal answer
Answer

Press the `q` key (for quit).

Question

Why faster?

Click to reveal answer
Answer

Because `less` does not read the entire file into RAM before starting. It only reads the tiny chunk of text needed to fill your current screen, making it open 100GB files instantly.