XZ Utils is a set of free softwarecommand-linelossless data compressors, including LZMA and xz, for Unix-likeoperating systems and, from version 5.0 onwards, Microsoft Windows. xz achieves higher compression rates than alternatives like gzip and bzip2. Decompression speed is faster than bzip2, but slower than gzip. Compression can be much slower than gzip, and is slower than bzip2 for high levels of compression, and is most useful when a compressed file will be used many times. XZ Utils consists of two major components:
Various command shortcuts exist, such as lzma, unxz and xzcat XZ Utils can compress and decompress both the xz and lzmafile formats, but since the LZMA format is now legacy, XZ Utils compresses by default to xz.
Implementation
Both the behavior of the software as well as the properties of the file format have been designed to work similarly to those of the popular Unix compressing tools gzip and bzip2. It consists of a Unix port of Igor Pavlov's LZMA-SDK that has been adapted to fit seamlessly into Unix environments and their usual structure and behavior. xz support multi-threaded compression since 2014, version 5.2.0., as of 2019 threaded decompression hasn’t been implemented yet.. Number of threads can be less than defined if file is not big enough for threading with the given settings or if using more threads would exceed the memory usage limit. Just like gzip and bzip, xz and lzma can only compress single files as input. They cannot bundle multiple files into a single archive – to do this an archiving program is used first, such as tar. Compressing an archive: xz my_archive.tar # results in my_archive.tar.xz lzma my_archive.tar # results in my_archive.tar.lzma Decompressing the archive: unxz my_archive.tar.xz # results in my_archive.tar unlzma my_archive.tar.lzma # results in my_archive.tar Version 1.22 or greater of the GNU implementation of tar has transparent support for tarballs compressed with lzma and xz, using the switches--xz or -J for xz compression, and --lzma for LZMA compression. Creating an archive and compressing it: tar -c --xz -f my_archive.tar.xz /some_directory # results in my_archive.tar.xz tar -c --lzma -f my_archive.tar.lzma /some_directory # results in my_archive.tar.lzma Decompressing the archive and extracting its contents: tar -x --xz -f my_archive.tar.xz # results in /some_directory tar -x --lzma -f my_archive.tar.lzma # results in /some_directory Single letter tar example for archive with compress and decompress with extract using short suffix tar cJf keep.txz keep # archive then compress the directory./keep/ into the file./keep.txz tar xJf keep.txz # decompress then extract the file./keep.txz creating the directory./keep/
Development and adoption
Development of XZ Utils took place within the Tukaani Project, which was led by Mike Kezner, by a small group of developers who once maintained a Linux distribution based on Slackware. All of the source code for xz and liblzma has been released into the public domain. The XZ Utils source distribution additionally includes some optional scripts and an example program that are subject to various versions of the GPL. Specifically, the full list of GPL scripts and sources distributed with the XZ Utils software include:
An optional implementation of a common libc function, getopt
An m4 script for pthread detection
Some nonessential wrapper scripts
And the example program scanlzma, which is not integrated with the build system
The resulting software xz and liblzma binaries are public domain, unless the optional LGPL getopt implementation is incorporated. Binaries are available for FreeBSD, Linux systems, Microsoft Windows, and FreeDOS. A number of Linux distributions, including Fedora, Slackware, Ubuntu, and Debian use xz for compressing their software packages. Arch Linux previously used xz to compress packages, but as of December 27, 2019, packages are compressed with Zstandard compression. The GNU FTP archive also uses xz.