LinuxCommandLibrary

unxz

Decompress .xz compressed files

TLDR

View documentation for the original command

$ tldr xz
copy

SYNOPSIS

unxz [options] [file ...]

PARAMETERS

-d, --decompress
    Force decompression. This is the default operation.

-k, --keep
    Keep (don't delete) input files.

-f, --force
    Force overwrite of output file. Normally, unxz will not overwrite an existing file.

-t, --test
    Test file integrity. No files are created or removed.

-v, --verbose
    Be verbose. Show the file name and compression ratio during decompression. Multiple uses increase verbosity.

-q, --quiet
    Be quiet. Suppress warnings; specify twice to suppress errors too.

-S .suf, --suffix=.suf
    Use suffix .suf on compressed files instead of .xz.

-z, --compress
    Force compression (this option is mostly relevant to xzcat).

--stdout
    Write to standard output. Only works when one file is specified.

--single-stream
    Decompress only the first stream; ignore any additional streams present in the input file. This is equivalent to xz --single-stream --robot --format=xz --stdout < infile > outfile.

-h, --help
    Display help and exit.

-V, --version
    Display version information and exit.

DESCRIPTION

The unxz command is a utility in Linux systems for decompressing files that have been compressed using the XZ compression algorithm. XZ compression is known for providing a high compression ratio, making it suitable for archiving and distributing files efficiently. unxz essentially reverses the process performed by the xz command, restoring the compressed file back to its original form.

When you run unxz on an .xz file, it decompresses the file and, by default, removes the original compressed .xz file. You can prevent this removal by using the -k option, which keeps the original compressed file after decompression.

If a file is detected to have multiple linked files, or is not of XZ format, the command will exit with an error. unxz is useful when you need to access the contents of a compressed archive created with XZ, such as software packages, documentation, or data files.

CAVEATS

unxz will not overwrite existing files unless the -f option is used. Ensure sufficient disk space is available before decompressing large files. Incorrect usage of -f may lead to unintentional data loss. The XZ Utils package must be installed for this command to function.

EXIT STATUS

The exit status is 0 on success, 1 for errors, and 2 for warnings. Using --test makes the exit status indicate the first error encountered during testing.

unxz can exit non-zero even if it has successfully extracted all the data. This can happen if an error occurred after successful extraction, for example, if the write of the output file failed.

MULTISTREAM SUPPORT

The XZ format supports having multiple compressed streams within a single file. unxz by default decompresses all the streams in a file, concatenating the results. The --single-stream option allows you to decompress only the first stream, ignoring the rest.

HISTORY

The xz format and utilities were developed as a successor to the LZMA compression format. It was created by Igor Pavlov and further developed by Lasse Collin and others. unxz is part of the XZ Utils package, which aims to provide a stable and efficient compression solution, particularly for archiving and distribution. The usage of XZ has increased over time due to its superior compression ratio compared to older formats like gzip.

SEE ALSO

xz(1), xzcat(1), gzip(1), bzip2(1)

Copied to clipboard