XZ Utils (previously LZMA Utils) is a set of free software command-line lossless data compressors, including the programs lzma and xz, for Unix-like operating systems and, from version 5.0 onwards, Microsoft Windows. For compression/decompression the Lempel–Ziv–Markov chain algorithm (LZMA) is used. XZ Utils started as 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 Utils
Original author(s)Lasse Collin
Developer(s)The Tukaani Project
Stable release
5.4.6 / 26 January 2024
Repository
Written inC
Operating systemCross-platform
TypeData compression
License
WebsiteArchived 2024-03-25 at the Wayback Machine
.xz
Filename extension
.xz
Internet media type
application/x-xz
Magic numberFD 37 7A 58 5A 00
Developed byLasse Collin
Igor Pavlov
Initial releaseJanuary 14, 2009; 15 years ago (2009-01-14)
Latest release
1.1.0
December 11, 2022; 17 months ago (2022-12-11)
Type of formatData compression
Open format?Yes
Free format?Yes
Websitetukaani.org/xz/xz-file-format.txt

Features edit

XZ Utils can compress and decompress the xz and lzma file formats. Since the LZMA format has been considered legacy,[2] XZ Utils by default compresses to xz.

In most cases, xz achieves higher compression rates than alternatives like gzip and bzip2. Decompression speed is higher than bzip2, but lower 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.[3][4]

XZ Utils consists of two major components:

Various command shortcuts exist, such as lzma (for xz --format=lzma), unxz (for xz --decompress; analogous to gunzip) and xzcat (for unxz --stdout; analogous to zcat).

Usage edit

Both the behavior of the software and the properties of the file format have been designed to work similarly to those of the popular Unix compressing tools gzip and bzip2.

Just like gzip and bzip, xz and lzma can only compress single files (or data streams) 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/

xz has supported multi-threaded compression (with the -T flag)[5] since 2014, version 5.2.0;[6] since version 5.4.0 threaded decompression has been implemented. Threaded decompression requires multiple compressed blocks within a stream which are created by the threaded compression interface. The number of threads can be less than defined if the file is not big enough for threading with the given settings or if using more threads would exceed the memory usage limit.[5]

The xz format edit

The xz format improves on lzma by allowing for preprocessing filters. The exact filters used are similar to those used in 7z, as 7z's filters are available in the public domain via the LZMA SDK.

Development and adoption edit

Development of XZ Utils took place within the Tukaani Project, 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 GNU General Public License (GPL).[1] The resulting software xz and liblzma binaries are public domain, unless the optional LGPL getopt implementation is incorporated.[7]

Binaries are available for FreeBSD, NetBSD, 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,[8] but as of December 27, 2019, packages are compressed with Zstandard compression.[9] Fedora Linux also switched to compressing its RPM packages with Zstandard with Fedora Linux 31.[10] The GNU FTP archive also uses xz.

Backdoor incident edit

On 29 March 2024, Andres Freund, a PostgreSQL developer working at Microsoft, announced that he had found a backdoor in XZ Utils, impacting versions 5.6.0 and 5.6.1. Compressed test files had been added to the code for setting up the backdoor via additions to the configure script in the tar files. He started his investigation because "After observing a few odd symptoms around liblzma (part of the xz package)" as he found that ssh logins using sshd were "taking a lot of CPU, valgrind errors".[11] The vulnerability received a Common Vulnerability Scoring System (CVSS) score of 10 (the highest).[12]

References edit

  1. ^ a b Licensing on tukaani.org "The most interesting parts of XZ Utils (e.g. liblzma) are in the public domain. You can do whatever you want with the public domain parts. Some parts of XZ Utils (e.g. build system and some utilities) are under different free software licenses such as GNU LGPLv2.1, GNU GPLv2, or GNU GPLv3."
  2. ^ LZMA Util, retrieved 2011-01-25
  3. ^ Henry-Stocker, Sandra (2017-12-12). "How to squeeze the most out of Linux file compression". Network World. Retrieved 2020-02-09.
  4. ^ "Gzip vs Bzip2 vs XZ Performance Comparison". RootUsers. 2015-09-16. Retrieved 2020-02-09.
  5. ^ a b "xz, unxz, xzcat, lzma, unlzma, lzcat – Compress or decompress .xz and .lzma files". Linux Manpages Online.
  6. ^ "XZ Utils Release Notes". git.tukaani.org.
  7. ^ "In what cases is the output of a GPL program covered by the GPL too?". GNU.org. Retrieved 21 August 2019.
  8. ^ Pierre Schmitz (2010-03-23). "News: Switching to xz compression for new packages".
  9. ^ "Arch Linux - News: Now using Zstandard instead of xz for package compression". www.archlinux.org. Retrieved 2020-01-07.
  10. ^ Mach, Daniel. "Changes/Switch RPMs to zstd compression". Fedora Project Wiki. Retrieved 30 March 2024.
  11. ^ "oss-security - backdoor in upstream xz/liblzma leading to ssh server compromise". www.openwall.com. Retrieved 2024-04-08.
  12. ^ "A backdoor in xz". LWN.net. Retrieved 2024-03-30.

External links edit