Linux xz Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux xz Guide
Complete beginner-friendly guide to xz on Linux, covering Arch Linux, CachyOS, and other distributions including file compression, decompression, and archive management.
Table of Contents
Understanding xz
What is xz?
xz compresses files with excellent compression.
Features:
- Best compression: Excellent compression ratio
- Slower: Slower than gzip/bzip2
- .xz format: Creates .xz files
- LZMA algorithm: Uses LZMA2 algorithm
Why it matters:
- Best compression: Smallest files
- Archive format: Common format
- Space saving: Maximum space saved
xz Basics
Compress File
Basic usage:
# Compress file
xz file.txt
# Creates: file.txt.xz
# Original file is removed
Keep Original
Preserve original:
# Keep original file
xz -k file.txt
# -k = keep (keeps original)
Compressing Files
Compression Level
Set level:
# Compression level (0-9)
xz -9 file.txt
# -9 = maximum compression
# -0 = fastest compression
Verbose Mode
Show progress:
# Verbose mode
xz -v file.txt
# -v = verbose (shows compression info)
Decompressing Files
Decompress
Extract:
# Decompress
unxz file.txt.xz
# Or
xz -d file.txt.xz
# Creates: file.txt
Test Archive
Test integrity:
# Test archive
xz -t file.txt.xz
# -t = test (checks integrity)
Troubleshooting
xz Not Found
Check installation:
# Check xz
which xz
# Install if missing
sudo pacman -S xz
Summary
This guide covered xz usage, file compression, and decompression for Arch Linux, CachyOS, and other distributions.
Next Steps
- gzip Guide - gzip compression
- bzip2 Guide - bzip2 compression
- Compression Tools - Compression overview
- xz Documentation:
man xz
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.