lzmainfo reads the header of an old-style .lzma file and reports its dictionary size and compression settings, without touching the archive. You will finish with a quick, read-only way to check a legacy .lzma file's dictionary size, compression properties and, when available, uncompressed size. The examples use lzmainfo from XZ Utils 5.8.2, provided here by the Debian xz-utils package version 5.8.2-1.1.
Allow about ten minutes. You need a shell and a readable file in the legacy .lzma format. No elevated privileges are needed. The command does not decompress, rewrite or delete the file it examines.
Confirm which executable will run and record its version. These are ordinary, read-only checks:
$ command -v lzmainfo
/usr/bin/lzmainfo
$ lzmainfo --version
lzmainfo (XZ Utils) 5.8.2
$ dpkg-query -W -f='${Package} ${Version}\n' xz-utils
xz-utils 5.8.2-1.1
Your package revision can differ. The version matters when you are comparing diagnostic wording or reproducing a result on another machine. The basic header fields used below are part of the command's long-standing interface.
Pass the path as an ordinary argument. The command reads the header and prints a human-readable report:
$ lzmainfo /path/to/archive.lzma
/path/to/archive.lzma
Uncompressed size: Unknown
Dictionary size: 8 MB (2^23 bytes)
Literal context bits (lc): 3
Literal pos bits (lp): 0
Number of pos bits (pb): 2
The blank line and file name are normal for file input. The values are taken from the first 13 bytes of the file, which is the .lzma header. They describe the stream settings; they are not a decompression progress report.
Checkpoint: The useful fields are present and the command returned to the prompt. Confirm the status explicitly when using it in a script:
$ lzmainfo /path/to/archive.lzma > /tmp/lzmainfo-report.txt
$ printf 'exit status: %s\n' "$?"
exit status: 0
Writing the report to /tmp is optional. If you redirect to a file that already exists, the shell truncates it before starting the command. Choose a new path when the old report matters.
MB for compatibility with the older LZMA Utils output: 8 MB (2^23 bytes) means 8 MiB in the binary sense, not eight million decimal bytes.lzmainfo inspects the header only; use xz --format=lzma --decompress when you need to test or extract the payload.Unknown. That is expected for the streamed .lzma variant, where the header does not carry a known final size. It is not evidence that the file is corrupt.When there is no file argument, lzmainfo reads standard input. A single hyphen is also the documented way to request standard input:
$ cat /path/to/archive.lzma | lzmainfo
Uncompressed size: Unknown
Dictionary size: 8 MB (2^23 bytes)
Literal context bits (lc): 3
Literal pos bits (lp): 0
Number of pos bits (pb): 2
$ lzmainfo - < /path/to/archive.lzma
Uncompressed size: Unknown
Dictionary size: 8 MB (2^23 bytes)
Literal context bits (lc): 3
Literal pos bits (lp): 0
Number of pos bits (pb): 2
The two commands should describe the same header. The second form is usually clearer in a script because the input redirection is visible and does not add a separate process. Do not use lzmainfo as though it accepted an .xz file automatically: .xz is a different container format.
If you need to verify a pipeline without touching an existing archive, create a temporary legacy file with xz. This writes only under /tmp and leaves the source text in place:
$ printf '%s\n' 'header inspection test' > /tmp/lzmainfo-input.txt
$ xz --format=lzma --stdout /tmp/lzmainfo-input.txt > /tmp/lzmainfo-input.lzma
$ lzmainfo /tmp/lzmainfo-input.lzma
/tmp/lzmainfo-input.lzma
Uncompressed size: Unknown
Dictionary size: 8 MB (2^23 bytes)
Literal context bits (lc): 3
Literal pos bits (lp): 0
Number of pos bits (pb): 2
The source is deliberately short, but the generated stream still demonstrates the header format. Remove these temporary files only when you are finished checking them:
$ rm -- /tmp/lzmainfo-input.txt /tmp/lzmainfo-input.lzma
Destructive action: This cleanup is limited to the two explicit temporary paths, but there is no undo command for removal, so do not substitute a directory or a wildcard.
A truncated header cannot be decoded. The command exits with status 1 and reports that the file is too small:
$ lzmainfo /path/to/truncated.lzma
lzmainfo: /path/to/truncated.lzma: File is too small to be a .lzma file
$ printf 'exit status: %s\n' "$?"
exit status: 1
Check the path and size before investigating compression settings:
$ ls -l /path/to/archive.lzma
$ test -r /path/to/archive.lzma && echo readable
readable
If the report says Not a .lzma file, check whether the input is actually an .xz stream or another format. File-name suffixes are hints, not proof. The local file command can provide a second opinion:
$ file /path/to/archive.lzma
/path/to/archive.lzma: LZMA compressed data, streamed
Do not run sudo to fix a format error. Elevated access cannot turn an .xz stream into a .lzma stream, and it is unnecessary for files you can already read.
lzmainfo and xz-utils versions..lzma header without changing the source file.Unknown uncompressed size.