LinuxCommandLibrary

lzma

Compress or decompress files using LZMA algorithm

TLDR

View documentation for the original command

$ tldr xz
copy

SYNOPSIS

lzma [options] [file...]
lzma -d [options] [file...]
lzcat [options] [file...] (alias for lzma -dc)

PARAMETERS

-d, --decompress, --uncompress
    Decompress files.

-z, --compress
    Compress files. This is the default action.

-k, --keep
    Do not delete input files after compression or decompression.

-f, --force
    Force overwrite of existing output files.

-c, --stdout, --to-stdout
    Write output to standard output, keeping input files intact.

-v, --verbose
    Display progress and verbose information during operation.

-q, --quiet
    Suppress all messages and warnings.

-t, --test
    Test the integrity of compressed files.

-l, --list
    List the contents of compressed files.

-[0-9]
    Compression preset. -0 is fastest/least compression, -9 is slowest/best compression.

DESCRIPTION

The lzma command is a powerful utility for compressing and decompressing files using the Lempel-Ziv-Markov chain Algorithm (LZMA).

Known for its exceptionally high compression ratios, especially on large files, lzma often achieves better compression than older algorithms like gzip or bzip2. By default, it replaces the original input file with the compressed or decompressed version. Compressed files typically have a .lzma extension.

On modern Linux systems, lzma is frequently provided as a compatibility symlink to the more advanced xz utility, which uses the LZMA2 algorithm. While lzma can often decompress .xz files, xz is generally recommended for new compression tasks due to its improved features, better error handling, and support for multi-threading.

CAVEATS

Although powerful, lzma has largely been superseded by xz for most modern compression tasks. xz offers better features, including multi-threading and more robust error handling.

While lzma provides high compression ratios, it can be significantly slower than gzip or bzip2, especially at higher compression levels.

It's important to note that, unlike some other compression tools, lzma does not perform integrity checks by default during compression, only during decompression or when explicitly using the -t option.

USING WITH STANDARD INPUT/OUTPUT

lzma can be effectively used in pipelines by reading from standard input and writing to standard output using the -c (or --stdout) option. This is common when compressing or decompressing archives without creating intermediate files. For example, to compress a tar archive: tar cf - . | lzma -c > archive.tar.lzma

HISTORY

The LZMA algorithm itself was developed by Igor Pavlov as part of the 7-Zip project, renowned for its high compression efficiency. The standalone lzma command-line utility emerged from this work to provide a dedicated tool for LZMA compression and decompression in Unix-like environments.

Over time, the need for a more versatile and feature-rich utility led to the development of xz. xz incorporated the improved LZMA2 algorithm and provided a unified interface for both LZMA and LZMA2 formats, along with better error handling and support for features like multi-threading. Consequently, lzma is now often provided as a symbolic link to xz on modern Linux distributions, ensuring backward compatibility for scripts and users familiar with the original command.

SEE ALSO

xz(1): The modern successor to lzma, using the LZMA2 algorithm and offering more features., gzip(1): A widely used compression utility based on the DEFLATE algorithm., bzip2(1): Another popular compression utility known for good compression ratios, using the Burrows-Wheeler transform., tar(1): An archiving utility often used in conjunction with compression tools (e.g., `tar Jcvf` for xz).

Copied to clipboard