How to Read Compressed xz Files Using the xzmore Command in Linux

When you compress a massive database dump using the modern xz utility, the resulting .xz file is highly compressed and completely unreadable by standard terminal tools like cat. If you simply need to view the contents of the file, decompressing the entire massive archive back to your hard drive just to read a few lines is incredibly inefficient. While most modern users rely on xzless, Linux also provides the legacy xzmore command to read compressed data on the fly.

How the xzmore Command Works

The xzmore utility acts as a bridge between the xz decompression algorithm and the very old, very basic more terminal pager. When you run it against a compressed file, it decompresses the data directly into your computer’s RAM, rather than writing it to the hard drive, and immediately pipes that readable text to your screen.

To read a compressed text file named archive.txt.xz, simply run:

xzmore archive.txt.xz

Navigating with xzmore

Because the output is routed through the legacy more pager, your navigation options are extremely limited compared to modern tools.

Once the file opens in your terminal, the text will stop at the bottom of the first screen. In the bottom left corner, you will see a percentage (e.g., --More--(12%)), indicating how much of the file you have viewed.

  • Enter Key: Press the Enter key to advance the text exactly one single line.
  • Spacebar: Press the Spacebar to advance the text exactly one full page (or screen) at a time.

The Critical Limitation: The more pager is strictly unidirectional. You can only scroll down. You cannot use your arrow keys to scroll up, and you cannot jump backward to a previous page. If you accidentally skip past the paragraph you wanted to read, you must quit the program entirely and start over from the beginning.

To quit the pager and return to your standard bash prompt, simply press the q key at any time.

Searching for Text

Despite its limitations, xzmore does support basic forward-searching.

  1. While viewing the file, type a forward slash (/).
  2. Type the word you are looking for and press Enter.
  3. The pager will jump forward to the first occurrence of that phrase.

Because you cannot scroll backward, if the word you searched for actually occurred on page 1, and you were currently reading page 5 when you initiated the search, xzmore will fail to find it, as it only searches the text that lies ahead.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.