xz
The xz command is a data compression utility with a high compression ratio. It generally yields better compression than gzip or bzip2, but can take longer and use more memory to compress.
Basic Syntax
xz [OPTION]... [FILE]...
Common Options
| Option | Description |
|---|---|
-d, --decompress | Decompress files (equivalent to unxz). |
-k, --keep | Keep (don't delete) input files. |
-z, --compress | Force compression (default). |
-1 to -9 | Compression preset (default is -6). |
-T threads, --threads=threads | Specify the number of worker threads to use. |
Real-world Examples
-
Compress a file (replaces file with
file.xz):xz large_database.sql -
Compress a file and keep the original:
xz -k large_database.sql -
Decompress an
.xzfile:xz -d archive.tar.xz(Alternatively, use
unxz archive.tar.xz) -
Compress using multiple threads to speed up the process:
xz -T 4 large_file.bin