LinuxCommandLibrary

lzip

Compress files using the Lempel-Ziv algorithm

TLDR

Archive a file, replacing it with with a compressed version

$ lzip [path/to/file]
copy

Archive a file, keeping the input file
$ lzip [[-k|--keep]] [path/to/file]
copy

Archive a file with the best compression (level=9)
$ lzip [[-k|--keep]] [path/to/file] --best
copy

Archive a file at the fastest speed (level=0)
$ lzip [[-k|--keep]] [path/to/file] --fast
copy

Test the integrity of compressed file
$ lzip [[-t|--test]] [path/to/archive.lz]
copy

Decompress a file, replacing it with the original uncompressed version
$ lzip [[-d|--decompress]] [path/to/archive.lz]
copy

Decompress a file, keeping the archive
$ lzip [[-d|--decompress]] [[-k|--keep]] [path/to/archive.lz]
copy

List files which are in an archive and show compression stats
$ lzip [[-l|--list]] [path/to/archive.lz]
copy

SYNOPSIS

lzip [option]... [file]...
lzip -d | --decompress [option]... [file]...

PARAMETERS

-0...-9
    Set compression level. -0 is fastest, -9 is best compression. Default is -6.

--fast
    Alias for compression level -0.

--best
    Alias for compression level -9.

-c, --stdout, --to-stdout
    Write output to standard output, keep original files.

-d, --decompress
    Decompress files.

-f, --force
    Overwrite existing output files without prompting.

-h, --help
    Display help message and exit.

-k, --keep
    Keep (don't delete) original input files after compression/decompression.

-L, --lazy
    Use lazy match finding. Improves compression ratio at the expense of speed.

-m, --memory=
    Set memory usage limit for compression (e.g., 20MB, 100%).

-o, --output=
    Write output to a specific file instead of modifying the original.

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

-S, --suffix=
    Use a specified suffix (e.g., .lz) instead of the default .lz for compressed files.

-t, --test
    Test compressed file integrity without decompressing.

-U, --uncompressed
    Restore uncompressed size. Primarily used with --force when target disk space might be an issue.

-v, --verbose
    Print verbose messages during operation.

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

DESCRIPTION

lzip is a free, powerful, and lossless data compressor based on the LZMA (Lempel-Ziv-Markov chain Algorithm) algorithm. It aims for a very high compression ratio, often surpassing gzip, bzip2, and even xz for many data types, especially large files. While lzip offers superior compression, it typically comes at the cost of increased compression and decompression time, and higher memory consumption during the compression phase.

It processes single files, replacing the original with a compressed version, or can output to standard output. lzip is designed with data integrity in mind, including an integrity check (CRC-32) in its file format to detect corruption. Its primary use case is for archiving and distributing large files where maximum compression is desired, and speed is less critical than file size.

CAVEATS

While lzip offers excellent compression, its main drawbacks are:
Speed: Both compression and decompression can be significantly slower than gzip or bzip2, and often xz.
Memory Usage: Compression, especially at higher levels, can consume a substantial amount of RAM. Decompression uses less but still more than gzip.
Parallelism: The standard lzip program is single-threaded. For parallel operation, plzip (parallel lzip) is available, but it's a separate utility.
Adoption: Less widely adopted than gzip or xz, which might make it less convenient for general file distribution without prior coordination.

FILE INTEGRITY

The lzip file format includes a 32-bit CRC (Cyclic Redundancy Check) to ensure data integrity. This allows detection of corrupted files during decompression or testing.

LONG-TERM ARCHIVING

Due to its stable file format, strong integrity checks, and high compression ratio, lzip is considered suitable for long-term data archiving where data fidelity is paramount.

CONVENIENCE SCRIPTS

lzip typically comes with helper scripts like lzcat (for decompressing to stdout), lzless (for viewing compressed text files), lzdiff (for comparing compressed files), and lzgrep (for searching patterns in compressed files).

HISTORY

The lzip project, led by Antonio Diaz Diaz, began in 2008 with the goal of providing a free and open-source implementation of the LZMA algorithm, focusing on a clean and robust file format suitable for long-term archiving. It was designed to address perceived limitations in other LZMA implementations, such as lzma (part of XZ Utils prior to XZ) regarding data integrity and format stability. The project emphasizes data recovery and error detection. Its development has been driven by a commitment to software freedom and a stable file format.

SEE ALSO

lzcat(1), lzless(1), lzdiff(1), lzgrep(1), xz(1), gzip(1), bzip2(1), tar(1), plzip(1)

Copied to clipboard