lzma: Legacy .lzma Compression and unlzma
lzma compresses files to the older .lzma (LZMA1) format, provided by xz-utils, with a similar interface to xz but without the newer container.
lzma is the predecessor to xz. You mostly meet it when decompressing old .lzma artifacts; for new work, xz (.xz) is the maintained choice.
What it does
lzma compresses input with the LZMA1 algorithm and the legacy .lzma container, provided by the xz-utils package as an alias mode of xz. unlzma or lzma -d decompresses, and lzcat streams to stdout. The .xz format supersedes it with integrity checks and multi-stream support.
Common usage
lzma -9 old.tar # -> old.tar.lzma
lzma -k -6 data.bin # keep source
unlzma legacy.tar.lzma # decompress
lzma -d archive.lzma # same as unlzmaOptions
| Flag | What it does |
|---|---|
| -9 | Maximum compression |
| -k / --keep | Keep the input file |
| -c / --stdout | Write to stdout |
| -d / --decompress | Decompress (like unlzma) |
| -t / --test | Test integrity |
| -F lzma (on xz) | Force the legacy lzma format when calling xz |
In CI
Prefer xz for anything new: .xz adds a CRC check and multi-threading (-T0) that .lzma lacks. Keep lzma around only to read legacy .lzma artifacts. It ships with xz-utils, so installing xz-utils gives you both.
Common errors in CI
"xz: (stdin): File format not recognized" on an .lzma file usually means you called xz -d without -F lzma on a raw stream, or the file is not actually lzma. "Cannot allocate memory" at -9 mirrors xz: LZMA1 -9 also needs a large dictionary. "command not found" means xz-utils is not installed.