Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

xz, unxz, xzcat

Compress files to .xz with very good compression (xz), unpack them (unxz), or read them (xzcat).

Niveau
Dagelijks Linux
Groep
Archiveren en comprimeren
Root nodig
Nee
Pakket
xz
Ook
unxz, xzcat, xzgrep

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

xz usually makes the smallest files of the classic tools, but it uses more time and memory. It is used for kernel modules, software packages and long-term archives.

xz FILE makes FILE.xz and removes the original. With tar, use -J (tar -cJf).

Zo schrijf je het

xz [OPTION]... [FILE]...
unxz [OPTION]... [FILE]...
xzcat [OPTION]... [FILE]...

Opties 21

Meest gebruikt

-z, --compress
Compress (the default).
-d, --decompress, --uncompress
Decompress (same as unxz).
-k, --keep
Keep the original file.
-c, --stdout
Write to the screen (stdout), keep the files.
-l, --list
Show information about .xz files (sizes, ratio, check type).
-t, --test
Test the file.
-f, --force
Overwrite existing files and compress links.
-0 ... -9
Compression level. Default 6. Higher = smaller and slower.
-e, --extreme
Try harder for a smaller file (more CPU time).
-T, --threads=n
Use N threads. 0 = as many as there are CPU cores.
-q, --quiet
Hide warnings (twice: hide errors too).
-v, --verbose
Show progress (twice: more).
-F, --format=fmt
File format: auto, xz, lzma, raw.
-C, --check=check
Integrity check type: none, crc32, crc64, sha256.
--memlimit=limit
Limit the memory use.
-S, --suffix=suf
Use another ending than .xz.
--single-stream
Decompress only the first stream.
--no-sparse
Do not make sparse files on decompress.
--block-size=size
Start a new block every SIZE bytes (for multi-thread).
-h, --help
Show help (-H for the long help with advanced options).
-V, --version
Show the version.

Voorbeelden 11

$ als gewone gebruiker# als root (of met sudo)

  1. 1Compress a file

    xz big.sql

    You get big.sql.xz.

  2. 2Decompress

    unxz big.sql.xz

    Same as xz -d big.sql.xz.

  3. 3Compress fast with all CPU cores

    xz -T0 -k vm-disk.raw

    -T0 uses all cores; -k keeps the original.

  4. 4Make a tar.xz archive

    tar -cJf logs-2026.tar.xz /var/log/archive

    Good for archives you keep for a long time.

  5. 5Read without unpacking

    xzcat app.log.xz | grep -c ERROR

    Count errors in a compressed log.

  6. 6Show details of a compressed file

    xz -l app.log.xz

    Compressed size, uncompressed size, ratio and check type.

  7. 7Best possible compression

    xz -9e release-notes.tar

    Very slow but very small. Good for files you send many times.

  8. 8Check a downloaded file

    xz -t image.xz && echo OK

    Finds broken downloads.

  9. 9Look at a compressed kernel module

    ls /lib/modules/$(uname -r)/kernel/drivers/net/ethernet/intel/ | head

    RHEL ships kernel modules as .ko.xz files.

  10. 10Unpack a cloud image

    xz -dk rhel-10-cloud.raw.xz

    Many cloud and SD-card images are delivered as .xz.

  11. 11Limit memory on a small machine

    xz --memlimit=256MiB -d huge.xz

    xz stops with an error instead of using too much RAM.

Let op

  • xz removes the original by default; use -k.
  • High levels (-9, -e) need a lot of RAM and time.

Tips om te onthouden

  • Size: xz < bzip2 < gzip. Speed: gzip > bzip2 > xz. In tar: z = gzip, j = bzip2, J = xz.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man xz