๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

๐Ÿ’ก Compression & Archives October 4, 2026 15

Linux Command: bzip2

Compress files using Burrows-Wheeler block sorting

Terminal โ€” Compression & Archives
Command
$ bzip2 large_dump.sql

bzip2 compresses files using the Burrows-Wheeler algorithm, typically producing better compression than gzip but running slower. Compressed files get the .bz2 extension. bzip2 offers significantly better compression ratios than gzip, typically 10-20% smaller files, at the cost of being 2-3x slower. It is commonly used for distributing large files where download size matters more than compression speed. bzip2 works on single files only. For directories, use tar cjf archive.tar.bz2 to combine tar archiving with bzip2 compression.

Syntax

bzip2 [OPTION]... [FILE]...

Key Options

  • -d โ€” Decompress
  • -k โ€” Keep original file
  • -1 to -9 โ€” Compression level
  • -z โ€” Force compression
  • -v โ€” Verbose
  • -c โ€” Write to stdout

Examples

Compress a file

bzip2 large_dump.sql

Decompress

bzip2 -d file.bz2

Keep original

bzip2 -k data.csv

Pro Tips

  • Speed: gzip > bzip2 > xz. Compression: xz > bzip2 > gzip. For daily backups use gzip. For distribution use xz.
  • bzip2 decompression is also slower than gzip. For files accessed frequently, gzip may be more practical.
  • Install pbzip2 for multi-threaded bzip2 compression. Dramatically faster on multi-core systems.

Learn more: Full bzip2 reference โ†’

Share this tip