The error message “bash: xz: command not found” surfaces in Linux terminal sessions when system administrators attempt to decompress .tar.xz source tarballs, extract Linux kernel archives, or execute automated software compilation scripts. The xz compression utility provides high-ratio LZMA/LZMA2 compression algorithms. Minimal server distributions, cloud templates, and lightweight Docker containers exclude xz by default to preserve minimal image footprints.
Install xz on Debian, Ubuntu, and Linux Mint
On Debian-derived distributions, xz is packaged under the xz-utils package name:
- Update your local APT repository index:
sudo apt update - Install the xz-utils package:
sudo apt install -y xz-utils - Verify that the binary is available in your shell execution path:
which xz xz --version
Install xz on RHEL, CentOS, Rocky Linux, and Fedora
Enterprise Red Hat derivatives distribute the utility directly under the package name xz:
- On Fedora, RHEL 8/9, Rocky Linux, and AlmaLinux:
sudo dnf install -y xz - On legacy CentOS 7 servers:
sudo yum install -y xz - Verify package installation details:
rpm -qi xz
Install xz in Alpine Linux Docker Containers
Alpine Linux container images support xz through the standard Alpine package repository:
- Update the Alpine package repository index:
apk update - Install the xz package:
apk add xz - In automated Dockerfile build manifests, include the package during image provisioning:
RUN apk add --no-cache xz
Decompress .tar.xz Archives Using Tar Directly
Modern versions of GNU tar can automatically detect and decompress xz streams once the binary is installed:
- To extract an xz-compressed archive:
tar -xf archive.tar.xz - To manually decompress a standalone
.xzfile without tar extraction:xz -d file.txt.xz
Installing the xz package restores high-efficiency LZMA decompression and seamless archive extraction across minimal Linux environments.