LinuxCommandLibrary

bzip3

Compress files using Burrows-Wheeler algorithm

TLDR

Compress a file

$ bzip3 [path/to/file_to_compress]
copy

Decompress a file
$ bzip3 [[-d|--decode]] [path/to/compressed_file.bz3]
copy

Decompress a file to stdout
$ bzip3 [[-dc|--decode --stdout]] [path/to/compressed_file.bz3]
copy

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

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

Decompress a file overwriting existing files
$ bzip3 [[-d|--decode]] [[-f|--force]] [path/to/compressed_file.bz3]
copy

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

SYNOPSIS

bzip3 [-1|-9] [-d|--decompress] [-t|--test] [-k|--keep] [-f|--force] [-c|--stdout] [-v|--verbose] [-q|--quiet] [-pN|--threads=N] [-bN|--block-size=N] [-s|--small] [--lzna] [--lzma] [--lzma-small] [--help] [filenames...]

PARAMETERS

-1 to -9
    Set compression level: -1 fastest, -9 best ratio (default -5)

-d, --decompress
    Decompress files (also triggered by .bz3/.bz extension)

-t, --test
    Test integrity of compressed files without decompression

-k, --keep
    Keep input files after processing (default: delete)

-f, --force
    Force overwrite of existing files and ignore prompts

-c, --stdout
    Compress/decompress to standard output

-v, --verbose
    Verbose output showing compression ratios and stats

-q, --quiet
    Suppress non-error messages

-pN, --threads=N
    Use N threads for compression/decompression (default: cores)

-bN, --block-size=N
    Set max block size to N MiB (2-4096, default 250)

-s, --small
    Small mode: lower memory, slightly worse ratios

--lzna
    Use LZNA compression mode for better ratios

--lzma
    Use full LZMA compression (high ratio, slower)

--lzma-small
    LZMA with small dictionary (faster than --lzma)

-h, --help
    Display help and exit

DESCRIPTION

bzip3 is a modern, high-performance compression tool designed as a successor to the classic bzip2. It uses the Burrows-Wheeler transform (BWT) followed by Huffman coding for loss-less data compression, delivering superior speed and ratios on multi-core systems thanks to native multi-threading. Unlike bzip2, bzip3 supports up to 32 threads (-p32), larger block sizes up to 4096 MiB (-b4096), and reduced memory usage. It fully decompresses bzip2 (.bz) files but produces incompatible .bz3 output.

Key enhancements include optional LZNA (--lzna) and LZMA (--lzma, --lzma-small) modes for better compression ratios, CRC64 integrity checks, and sparse file handling. Compression levels range from -1 (fastest) to -9 (best ratio). It's ideal for archiving large datasets, backups, and software distribution where speed matters. Benchmarks show it outperforming bzip2 by 3-10x in speed while matching or exceeding ratios. Available in most modern Linux distros via package managers.

CAVEATS

bzip3 output (.bz3) incompatible with bzip2 compressors; high levels (-9) use gigabytes of RAM; LZMA modes slower but denser; still maturing, check distro support.

FILE EXTENSIONS

Uses .bz3 for new files; auto-detects .bz, .bz2, .tbz for decompression.
stdin/stdout with no extension.

PERFORMANCE TIP

Best speed/ratio balance at -5 to -7 with -p matching cores; scales to 8+ threads efficiently.

HISTORY

Developed by Nikita Zhogin starting 2019; v1.0.0 released 2023. Fixes bzip2 limitations like single-threading and small blocks; gained traction for speed in HPC/archiving.

SEE ALSO

bzip2(1), gzip(1), xz(1), zstd(1)

Copied to clipboard