الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

xz, unxz, xzcat

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

المستوى
لينكس اليومي
المجموعة
الأرشفة والضغط
يحتاج root
لا
الحزمة
xz
يُسمّى أيضًا
unxz, xzcat, xzgrep

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

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).

طريقة الكتابة

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

الخيارات 21

الأكثر استخدامًا

-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.

أمثلة 11

$ مستخدم عادي# بصلاحية root (أو مع 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.

انتبه

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

نصائح للحفظ

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

الدليل الكامل

هذه الصفحة تشرح الأمر بكلمات بسيطة. الدليل الأصلي فيه كل التفاصيل.

في الطرفية: man xz