LinuxCommandLibrary

unxz

Decompress .xz compressed files

TLDR

View documentation for the original command

$ tldr xz
copy

SYNOPSIS

unxz [OPTION]... [FILE]...

PARAMETERS

-d, --decompress
    Decompress. This is the default operation when unxz is invoked, though explicitly specifying it has no additional effect.

-k, --keep
    Do not delete input files after successful decompression. The original .xz file will remain.

-f, --force
    Force overwrite output files and decompress symbolic links. This bypasses warnings for existing files.

-c, --stdout, --to-stdout
    Write output to standard output. Input files are not deleted. Useful for piping output to other commands.

-t, --test
    Test the integrity of the compressed files. No output is written to stdout, only the exit status indicates success or failure.

-l, --list
    List information about the compressed files, such as their compressed and uncompressed sizes, and integrity check type.

-q, --quiet
    Suppress all warnings and error messages. Only the exit status will indicate a problem.

-v, --verbose
    Be verbose. Show the name and percentage progress of each file as it is being processed.

-h, --help
    Display a brief help message summarizing common options and exit.

-V, --version
    Display the version information for xz (and thereby unxz) and exit.

DESCRIPTION

unxz is a command-line utility used to decompress files that have been compressed using the xz command or are in the XZ file format.

It is essentially a convenience script or symbolic link to the xz command, specifically invoking xz with the --decompress (or -d) option.

When invoked, unxz reads the compressed data from the specified input FILE(s) and writes the decompressed data to standard output by default, or to a new file named by stripping the .xz extension from the input filename. By default, the original compressed file is deleted after successful decompression.

It supports decompressing multiple files simultaneously and can also read from standard input if no FILE is specified, writing the decompressed output to standard output.

unxz is part of the xz-utils package, which provides a comprehensive set of tools for manipulating XZ compressed files.

CAVEATS

By default, unxz deletes the original .xz input file after successful decompression. Use the -k (--keep) option to retain it.

As unxz is typically a symlink or script calling xz -d, its behavior and available options are largely inherited from the underlying xz command. Any options not recognized by xz will result in an error.

EXIT STATUS

0 on success.
1 on error (e.g., input file not found, bad arguments, corrupted input).
2 on warning (e.g., integrity check failed for -t, or other non-fatal issues).

ENVIRONMENT VARIABLES

The XZ_OPT environment variable can be used to specify default options to xz (and thus unxz) before any command-line options. For example, export XZ_OPT=-k would make unxz keep input files by default unless overridden on the command line.

TYPICAL USAGE

Decompress a single file, deleting the original:
unxz archive.tar.xz

Decompress a file and keep the original:
unxz -k document.txt.xz

Decompress to standard output (useful for piping):
unxz -c data.log.xz | less

Test the integrity of a compressed file:
unxz -t backup.sql.xz

HISTORY

unxz is part of the xz-utils collection, developed by Lasse Collin, which primarily uses the LZMA2 compression algorithm. It emerged as a successor to LZMA Utils, offering improved compression ratios and performance compared to older formats like Gzip and Bzip2, especially for large files.

The xz-utils suite, including unxz, gained widespread adoption in Linux distributions and Unix-like systems, becoming a preferred standard for general-purpose compression due to its efficiency and the strong integrity checking capabilities provided by the XZ format.

SEE ALSO

xz(1), lzma(1), gzip(1), bzip2(1), tar(1)

Copied to clipboard