When you need to read a massive, compressed log file in Linux, extracting the file to your hard drive just to view it is incredibly inefficient. While utilities like bzcat will dump the uncompressed contents directly onto your screen, the text will likely scroll past much too quickly for you to read. To pause the output of a bzip2 archive and read it one page at a time, you should use the bzmore command.
How bzmore Works
The bzmore command is a dedicated wrapper script that combines the extraction power of bzip2 with the traditional more text pager. When you run it against a .bz2 file, it uncompresses the data into your system’s RAM, fills your terminal screen with exactly one page of text, and then pauses. It waits at the bottom of the screen with a prompt that displays the percentage of the file you have currently read, allowing you to control the flow of data.
Basic Usage and Navigation
To read a compressed file using this utility, simply type the command followed by the filename.
bzmore auth_logs.bz2
The screen will fill with the beginning of the uncompressed text. Because it relies on the classic more pager, you use the following keyboard inputs to navigate:
- Spacebar: Pressing the spacebar will advance the text forward by one full screen (or “page”).
- Enter (Return) Key: Pressing Enter will advance the text forward by exactly one single line.
- q key: Pressing the “q” key at any time will instantly quit the viewer and return you to the standard terminal prompt.
The Difference Between bzmore and bzless
If you are familiar with Linux pagers, you might wonder why you should use bzmore instead of bzless. The simple answer is that you probably shouldn’t, unless you are working on a very old or highly restricted system.
The more pager is a classic Unix utility, but it is notoriously limited: it only allows you to scroll forward. If you accidentally press the spacebar twice and skip past the error message you were looking for, you cannot scroll back up to see it. The bzless command, on the other hand, utilizes the modern less pager, which allows full bidirectional scrolling (using the up and down arrow keys) and advanced search capabilities. However, on minimal embedded systems or older servers where less is not installed, bzmore remains a vital fallback tool.