bzip2 — Compress and Decompress Files in Linux

bzip2 is a command-line tool for compressing files on Linux. It usually creates files with a .bz2 extension.

Compress a file

bzip2 filename.txt

This creates filename.txt.bz2 and removes the original file by default.

Decompress a file

bunzip2 filename.txt.bz2

To keep the original file while compressing or decompressing, use -k.

bzip2 -k filename.txt
bunzip2 -k filename.txt.bz2

Leave a Comment