Read Compressed Text Safely with xzmore and lzmore

xzmore pages through an xz or lzma text file one screenful at a time, with no unpacked copy left behind afterwards. Along the way you will pick a pager, move between several inputs, and spot the format mistake that trips people up most.

Allow about ten minutes. You need a shell, the XZ Utils command and a terminal that can run a pager. The examples only read files, need no elevated privileges, and never alter the compressed input.

The local manual page describes XZ Utils 5.6.1+really5.4.5-1ubuntu0.3 from the Ubuntu xz-utils package. On this machine, xzmore actually resolves to Homebrew XZ Utils 5.8.4 instead. That executable supports the same documented workflow, but keep the distinction in mind when comparing help text or troubleshooting another host.

1. Confirm the command and file format

Check which executable your shell will run, then ask it for its version. Both are ordinary, read-only commands:

$ command -v xzmore
/home/linuxbrew/.linuxbrew/bin/xzmore
$ xzmore --version
xzmore (XZ Utils) 5.8.4

Your path and version may differ. xzmore is built for files compressed with the xz or lzma formats; a name ending in .xz is only a naming convention, not proof of what is actually inside.

Checkpoint: If the origin of a file is unclear, test it before opening:

$ xz --test /path/to/notes.txt.xz
$ printf 'xz test status: %s\n' "$?"
xz test status: 0

A status of zero means the compressed stream passed the integrity test. It says nothing about whether the decompressed text is safe to execute, so treat the content as data, especially if it came from someone else.

2. Open one compressed text file

Pass the input path as an argument. xzmore decompresses the stream and sends it to the default pager, normally more:

$ xzmore /path/to/notes.txt.xz
------> /path/to/notes.txt.xz <------
first line of the decompressed text
another line of the decompressed text
--More--

The header names the current file; the pager controls everything after that. The prompt and the movement keys belong to the pager, not to xzmore, so for the usual more pager, press whatever the prompt shows or check man more.

Skip the shell redirection habit here: xzmore is already a viewing filter, and it does not write a decompressed copy beside the source.

3. Choose a different pager

Set PAGER for a single invocation when you want a different viewer, such as less, if it is installed:

$ PAGER=less xzmore /path/to/notes.txt.xz

The value is the name of the program that should receive the decompressed text. If that pager needs options, build the command string carefully and test it on a harmless input first: an untrusted value in PAGER can change how your shell evaluates the whole thing, so never populate it from a remote filename or other outside data.

For a script or a non-interactive check, plain decompression is clearer than xzmore, which is built entirely around an interactive pager and has no flag for selecting an output file.

4. Read several files and control the hand-off

Give xzmore more than one path to review files in sequence:

$ xzmore /var/log/example-2026-09-27.txt.xz /var/log/example-2026-09-28.txt.xz

After the first file, the prompt names the next one. At that prompt:

The detail that catches people out: s only works at that next-file prompt. It is not a general command for skipping lines inside the current pager view.

Checkpoint: If you are unsure which file is on screen, wait for the header or the next-file prompt rather than trusting the order you remember, which matters most when a shell glob decided the order for you.

5. Use the lzmore compatibility name

lzmore is the backward-compatible name for people coming from LZMA Utils, with the same argument shape and viewing behaviour:

$ lzmore /path/to/archive.txt.lzma

Use whichever name matches your existing scripts or documentation. The command name alone does not tell you the format: lzmore can view xz or lzma text just as well, provided the input really is a supported stream.

6. Diagnose the common failures

If xzmore errors out immediately, check the path and permissions first:

$ test -r /path/to/notes.txt.xz && echo readable
readable
$ file /path/to/notes.txt.xz

A file that is actually gzip compressed despite an .xz suffix is not an xzmore input, no matter what its name claims. Use the tool that matches the real format, such as zmore for gzip, once file has told you what you are dealing with. Renaming the file is not the same as converting it.

If a file is truncated or corrupt, xz --test normally returns non-zero. Stop there and get a fresh copy rather than trusting a partially displayed log or config file.

If lzmore is missing but xzmore exists, confirm both names actually come from the same XZ Utils installation:

$ command -v xzmore lzmore
$ readlink -f "$(command -v xzmore)"
$ readlink -f "$(command -v lzmore)"

Different resolved paths point to mixed package installations, which is a packaging problem for your system administrator or package manager to sort out, not a reason to add a stray symlink.

Done means