High-ratio compression using the XZ/LZMA algorithm.
low risk
xz provides high compression ratios using the LZMA2 algorithm — better compression than gzip at the cost of more CPU and memory. Widely used for distributing Linux kernel tarballs and large datasets. Works like gzip in its pipeline behavior.
| Flag | Meaning |
|---|---|
-d --decompress | Decompress |
-k --keep | Keep input file after compression |
-9 | Maximum compression level |
--threads --threads | Number of threads (0 = all CPUs) |
xz -k large-dataset.tarCompress keeping original file · explain & risk-check →xz -d archive.tar.xzDecompress xz archive · explain & risk-check →tar -cJf archive.tar.xz /data/Create xz-compressed tar archive · explain & risk-check →xz -T 0 -k bigfileCompress using all CPU cores · explain & risk-check →Use `xz -T 0` to enable multi-threaded compression on large files — xz is single-threaded by default and can be extremely slow without this flag.
Reference text is hand-written and may be incomplete — check man xz for your version. Test destructive commands on a non-production system first.