← 返回命令列表

Linux command

xz 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Compress a file

xz [file]

Decompress a file

xz -d [file.xz]

Compress with maximum compression

xz -9 [file]

Compress keeping the original file

xz -k [file]

Compress to stdout

xz -c [file] > [file.xz]

Decompress to stdout

xz -dc [file.xz]

List compressed file info

xz -l [file.xz]

Test compressed file integrity

xz -t [file.xz]

说明

xz is a general-purpose compression tool using the LZMA2 algorithm. It provides high compression ratios, often better than gzip and bzip2, though compression is slower. By default, xz compresses files and replaces them with .xz versions. Use -k to keep originals or -c to write to stdout for pipelines. Multi-threading support (-T) significantly speeds up compression on multi-core systems. Decompression is single-threaded but fast. The compression level affects both ratio and memory usage. Level 9 requires significantly more memory than lower levels, both for compression and decompression.

参数

-d, --decompress
Decompress files
-z, --compress
Compress files (default)
-k, --keep
Keep original file
-c, --stdout
Write to stdout, keep original file
-f, --force
Force compression/decompression
-t, --test
Test compressed file integrity
-l, --list
List information about compressed files
-0 to -9
Compression level (0=fast, 9=best compression)
-e, --extreme
More compression (slower)
-T _N_, --threads=_N_
Use N threads (0 = auto-detect cores)
-v, --verbose
Verbose output
-q, --quiet
Suppress warnings

FAQ

What is the xz command used for?

xz is a general-purpose compression tool using the LZMA2 algorithm. It provides high compression ratios, often better than gzip and bzip2, though compression is slower. By default, xz compresses files and replaces them with .xz versions. Use -k to keep originals or -c to write to stdout for pipelines. Multi-threading support (-T) significantly speeds up compression on multi-core systems. Decompression is single-threaded but fast. The compression level affects both ratio and memory usage. Level 9 requires significantly more memory than lower levels, both for compression and decompression.

How do I run a basic xz example?

Run `xz [file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -d, --decompress do in xz?

Decompress files