Archives

Linux xz command

Compress files using xz. The -k flag keeps the original file.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

xz [OPTION]... [FILE]...

Examples

Compress data.csv while preserving the original.

xz -k data.csv

Decompress while keeping the compressed file.

xz -dk data.csv.xz

Parameters, options and clauses

Option / clauseDescription
-z, --compressCompress (default operation).
-d, --decompressDecompress.
-k, --keepKeep the input file.
-c, --stdoutWrite results to standard output.
-T N, --threads=NUse up to N threads (where supported).
-0 to -9Set compression preset; higher values usually use more resources.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory