Interview Q&A / Linux & Shell

BeginnerQuick answer1 min readUpdated 3 Oct 2026

When should you use less instead of cat?

SHORT ANSWER

cat dumps the whole file to the terminal at once, which suits short files and pipelines. less opens a scrollable pager that loads lazily, lets you search with / and quit with q, so it is the right tool for large files.

Explain it simply

cat is like emptying a bucket on the floor; less is like reading a book page by page. For a 2-line config, the bucket is fine. For a 500 MB log, you want the book.

cat (short for concatenate) prints files one after another to standard output. It is also used to feed data into pipes. With a big file, your screen floods and the top scrolls away.

less shows one screenful, does not read the whole file up front, and has navigation: Space for next page, b for back, /word to search forward, n for the next match, G for the end, g for the start and q to quit. less +F file behaves like tail -f and Ctrl+C returns to normal mode.

The older more only moves forward; "less is more" is the joke behind the name.

Example

bash
cat /etc/hostname              # tiny file: cat is fine
less /var/log/syslog           # big file: use a pager
# inside less: type /error then press n to jump between matches

What to say in the interview

"I use cat for small files or to feed content into a pipe. For anything large I use less because it opens instantly, lets me scroll and search, and doesn't flood the terminal."

Common mistakes

  • Running cat on a huge log and filling the terminal buffer.

#linux#files#less

Related questions

Practise more Linux & Shell questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Linux & Shell quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.