When to use xz
Use xz when compressing a single stream with a chosen resource tradeoff. Compression settings affect memory and CPU use; preserving the original is useful while validating a newly generated compressed file.
Syntax
xz [OPTIONS] FILE…Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Compress in one stream
xz -k -T 1 ./report.txtA compressed copy is created using one compression thread while keeping the source.
Check integrity
xz -t ./report.txt.xzThe compressed stream is tested without creating an extracted file.
Output unpacked text
xz -dc ./report.txt.xzThe decompressed stream is displayed or can be piped to another command.
Notes and limitations
- High compression levels can require a lot of memory and CPU; choose them taking into account the server.
- Without -k, the normal operation replaces the original file. For directory tree use tar.
Common questions and troubleshooting
Does single-thread compression limit memory completely?
No. Dictionary and compression settings also determine memory demand. Check the local manual and resource budget for large inputs.
Does an integrity check verify the source's authenticity?
No. A valid stream can still contain unwanted data. Verify a trusted signature or checksum and inspect the intended contents separately.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man xz.