Home·Terminal commands

xz

Archives

Usage

xz [-T0] [-k] <file>

Gives the smallest output of the three common formats but is slow and wants roughly 700 MB of memory at `-9`; it runs single-threaded unless you add `-T0`, it removes the original without `-k`, and the tar flag for it is a capital `-J`.

Common flags

FlagMeaning
-kKeep the original.
-dDecompress; unxz is the same.
-T0Use every core. Single-threaded is the default.
-9Smallest output. Compression needs roughly 700 MB of RAM at this level.
-cWrite to stdout.
-lList what is inside a .xz file.

Examples

xz -T0 -9 huge.tar

Smallest possible archive, using all cores.

xz -dk archive.tar.xz

Unpack while keeping the compressed copy.

tar -cJf src.tar.xz ./src

The tar flag for xz is a capital -J.

Bundling and compressing are separate jobs: tar bundles, gzip shrinks, and .tar.gz is both.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does xz do?

Gives the smallest output of the three common formats but is slow and wants roughly 700 MB of memory at `-9`; it runs single-threaded unless you add `-T0`, it removes the original without `-k`, and the tar flag for it is a capital `-J`.

Q. How do I type it?

xz [-T0] [-k] <file> — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

6 are listed here; the full set is in man xz. This command sits under Archives.

Related commands

man page: man xz