Compression
xz
Compress files using the LZMA2 algorithm for very high compression ratios.
Synopsis
syntax
xz [OPTION]... [FILE]...
Examples
Compress file (creates large.log.xz)
xz large.log
Extreme best compression, keep original
xz -k -9e data.bin
Decompress file
xz -d archive.xz
Multi-threaded compression
xz -T0 -6 huge.tar
Common options
| Flag | Description |
|---|---|
| -d | Decompress |
| -k | Keep original file |
| -v | Verbose output |
| -T | Number of threads |
| -0 to -9 | Compression level |
| -e | Extreme compression |
About xz
The `xz` command compress files using the LZMA2 algorithm for very high compression ratios. Compression commands reduce file sizes for storage and transfer.
Linux supports multiple compression formats, each with different speed and ratio trade-offs. Understanding these tools is essential for working with archives, backups, log rotation, and software distribution packages.
The command accepts 6 commonly used flags shown above, though the full set of options is available in the man page (`man xz`). The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.
Related commands
More Compression Commands
Other commands in the Compression category