$linuxjunkies
>

pbzip2(1)

Compress or decompress files in parallel using the bzip2 algorithm.

UbuntuDebianFedoraArch

Synopsis

pbzip2 [OPTION]... [FILE]...

Description

pbzip2 is a parallel implementation of bzip2 that uses multiple processors to compress and decompress files faster than the standard bzip2. It produces output identical to bzip2 but leverages multi-core systems for improved performance.

When compressing, pbzip2 divides the input into blocks and processes them in parallel. When decompressing, it detects concatenated bzip2 streams and decompresses them concurrently. By default, it uses all available CPU cores.

Common options

FlagWhat it does
-dDecompress file instead of compressing
-cWrite output to stdout instead of a file
-kKeep input file (do not delete after compression/decompression)
-vVerbose mode; show compression ratio and processing details
-fForce overwrite of output file if it exists
-p NUMUse NUM parallel threads instead of auto-detecting CPU count
-m NUMUse NUM × 900KB blocks for compression (default 9); higher uses more memory
-qQuiet mode; suppress non-essential output
-1Compress faster using smaller blocks (equivalent to -m 1)
-9Compress better using larger blocks (equivalent to -m 9)

Examples

Compress largefile.txt to largefile.txt.bz2 using all available cores

pbzip2 largefile.txt

Decompress largefile.txt.bz2 back to largefile.txt in parallel

pbzip2 -d largefile.txt.bz2

Compress archive.tar to archive.tar.bz2, keep the original, and show progress

pbzip2 -k -v archive.tar

Compress to stdout and pipe directly to a remote server over SSH

pbzip2 -c largefile.txt | ssh user@host 'cat > remotefile.bz2'

Compress using exactly 4 threads with maximum compression ratio

pbzip2 -p 4 -9 bigdata.bin

Decompress and extract a tar archive in parallel in one pipeline

pbzip2 -d -c backup.tar.bz2 | tar -x

Related commands