How to Fix bash xz command not found in Minimal Linux

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:

  1. Update your local APT repository index:
    sudo apt update
  2. Install the xz-utils package:
    sudo apt install -y xz-utils
  3. 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:

  1. On Fedora, RHEL 8/9, Rocky Linux, and AlmaLinux:
    sudo dnf install -y xz
  2. On legacy CentOS 7 servers:
    sudo yum install -y xz
  3. 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:

  1. Update the Alpine package repository index:
    apk update
  2. Install the xz package:
    apk add xz
  3. 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:

  1. To extract an xz-compressed archive:
    tar -xf archive.tar.xz
  2. To manually decompress a standalone .xz file 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.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.