xz: command not found

The xz command is a data compression utility, similar to gzip, that reduces the size of selected files and manages files in the .xz file format. The xz command has several options.

Option Used To
-d Decompress a file.
-f Force compression or decompression of a file even if it has multiple links or if the file exists.
-q Suppress all warnings.
-v Display the name and percentage reduction of the compressed or decompressed file.
-t Perform an integrity check on the compressed file.

If you encounter the below error while running the xz command:

xz: command not found

you may try installing the below package as per your choice of distribution:

OS Distribution Command
OS X brew install xz
Debian apt-get install xz-utils
Ubuntu apt-get install xz-utils
Alpine apk add xz
Arch Linux pacman -S xz
Kali Linux apt-get install xz-utils
CentOS yum install xz
Fedora dnf install xz
Raspbian apt-get install xz-utils

Syntax

The syntax of the xz command is:

# xz [options] [file names]

xz Command Examples

1. Compress a file to the xz file format:

# xz file

2. Decompress a xz file:

# xz -d file.xz

3. Compress a file to the LZMA file format:

# xz --format=lzma file

4. Decompress an LZMA file:

# xz -d --format=lzma file.lzma

5. Decompress a file and write to stdout:

# xz -dc file.xz

6. Compress a file, but don’t delete the original:

# xz -k file

7. Compress a file using the fastest compression:

# xz -0 file

8. Compress a file using the best compression:

# xz -9 file
Related Post