LinuxCommandLibrary

bzip2

Compress files using block-sorting lossless algorithm

TLDR

Compress a file

$ bzip2 [path/to/file_to_compress]
copy

Decompress a file
$ bzip2 [[-d|--decompress]] [path/to/compressed_file.bz2]
copy

Decompress a file to stdout
$ bzip2 [[-dc|--decompress --stdout]] [path/to/compressed_file.bz2]
copy

Test the integrity of each file inside the archive file
$ bzip2 [[-t|--test]] [path/to/compressed_file.bz2]
copy

Show the compression ratio for each file processed with detailed information
$ bzip2 [[-v|--verbose]] [path/to/compressed_files.bz2]
copy

Decompress a file overwriting existing files
$ bzip2 [[-f|--force]] [path/to/compressed_file.bz2]
copy

Display help
$ bzip2 [[-h|--help]]
copy

SYNOPSIS

bzip2 [ flags ] [ filenames ... ]

PARAMETERS

-c, --stdout
    Force write output to standard output, even if to a terminal.

-d, --decompress
    Force decompression.

-z, --compress
    Force compression.

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

-h, --help
    Display help message.

-k, --keep
    Keep (don't delete) input files during compression or decompression.

-L, --license
    Display the bzip2 license.

-q, --quiet
    Suppress non-essential error messages.

-v, --verbose
    Be verbose. Shows compression ratio for each file processed.

-1 .. -9
    Set block size to 100k .. 900k when compressing. Higher values give better compression at the expense of more memory.

DESCRIPTION

bzip2 is a freely available, patent-free (see below), high-quality data compressor. It typically compresses ordinary text files to somewhere between 10% and 15% of their original size. It compresses better than more conventional programs like gzip, and achieves compression close to the PPM family of statistical compressors, while being considerably faster and using less memory.
bzip2 compresses single files at a time and is commonly used in conjunction with tar for archiving multiple files into a single compressed archive. Its primary use is for data compression to reduce storage space and improve transfer speeds of large files.

RECOVERY AFTER ERRORS

Bzip2 is designed to recover after errors. It detects block boundaries and will continue decompression from the next valid block.

HISTORY

bzip2 was first released in July 1996 by Julian Seward. It was designed as an alternative to gzip, offering significantly better compression ratios. It quickly gained popularity due to its efficiency and free availability. bzip2 is commonly used for distributing software packages, archiving data, and reducing the size of log files. Its consistent performance and open-source nature have made it a reliable tool in many systems.

SEE ALSO

gzip(1), tar(1)

Copied to clipboard