1. more — A Simple Pager

more is one of the simplest and oldest pager utilities in Linux. It allows you to view text files one screen at a time.

Basic Usage:

more filename.txt
  • It will display the content of filename.txt one page at a time.
  • After you reach the end of the screen, it will prompt you for further action.
  • Spacebar: Move to the next screen of text.
  • Enter: Move down one line at a time.
  • b: Move backward (one screen).
  • q: Quit and exit more.

While more works for basic file viewing, it is limited in terms of navigation and functionality.


2. less — A More Powerful Pager

less is a more powerful and flexible pager compared to more. It allows you to both scroll forward and backward in the file, which more does not support. It is the pager commonly used by man pages (manual pages) in Linux.

Basic Usage:

less filename.txt
  • This command will open filename.txt and allow you to view its contents with much more control over navigation.
  • Spacebar: Move to the next screen of text (like more).
  • Enter: Move down one line at a time.
  • b: Move backward one screen.
  • q: Quit and exit less.
  • Up/Down arrow: Scroll line by line up or down.
  • g: Go to the beginning of the file.
  • G: Go to the end of the file.
  • /search_term: Search for a specific term in the file. Press n to go to the next occurrence and N to go to the previous occurrence.

Extra Features of less:

  • Backward Navigation: You can scroll both forward and backward in the file, unlike more, which only lets you move forward.
  • Search: You can search for specific patterns or text inside the file by typing /search_term and pressing Enter.
  • Pipe Compatibility: less is often used in combination with other commands (using a pipe |), which allows you to scroll through the output of commands that generate large amounts of text.

For example:

dmesg | less

This command will display kernel messages, which can be quite lengthy, but using less, you can easily navigate through them.


Summary of Differences:

Featuremoreless
Forward NavigationYesYes
Backward NavigationNoYes
SearchNoYes
ScrollingOne screen at a time, limited controlsLine-by-line and screen-by-screen navigation
UsageSimple, older pager utilityMore powerful, flexible, and widely used

In general, less is preferred in most scenarios due to its advanced features and flexibility, but more is still useful for simpler cases when you just need to scroll forward through a file.