Unix paging utilities: Which command displays a text file one screenful at a time with a default page length of 24 lines, allowing you to move forward through the file content?

Difficulty: Easy

Correct Answer: pg

Explanation:


Introduction / Context:
When working at a Unix or Linux terminal, long files can scroll off the screen quickly. Pagers are utilities that show content a screenful at a time. Historically, the pg command uses a default page size of 24 lines, which is why many textbooks reference “view 24 lines at a time.” Knowing which pager provides that default helps with day-to-day system administration and exam questions alike.



Given Data / Assumptions:

  • The environment is a Unix-like shell.
  • The goal is to view a file interactively by pages, not to print it or dump it all at once.
  • The question calls out the classic default of 24 lines per page.


Concept / Approach:

Pagers offer interactive navigation. The pg utility (System V heritage) presents a file in 24-line chunks by default. It accepts navigation keystrokes (space to advance, q to quit). Other commands either do not paginate or are intended for different tasks (printing or raw output).



Step-by-Step Solution:

Identify the pager with a 24-line default: pg.Compare with more: more also paginates but is commonly tied to terminal height; the question’s signature phrasing points to pg.Exclude cat: it streams the entire file without paging.Exclude lp: lp sends jobs to the printer, not the screen.Therefore, choose pg as the correct command.


Verification / Alternative check:

Run pg /etc/services and press space to advance. You will see the content displayed page by page. For similar functionality with richer navigation, many modern systems use less, but the “24 lines” cue historically maps to pg.



Why Other Options Are Wrong:

  • more: A pager, but the question’s 24-line default is specifically associated with pg.
  • cat: No paging; prints everything at once.
  • lp: Submits a print job; not a viewer.
  • None of the above: Incorrect because pg satisfies the requirement.


Common Pitfalls:

Assuming all pagers behave identically. While more and less are common, certification-style questions often expect pg when “24 lines” is emphasized. Also remember that page length can be affected by terminal size settings and environment variables.



Final Answer:

pg

More Questions from Unix

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion