How to Install Bzip2 on Ubuntu

Techwalla may earn compensation through affiliate links in this story.
Use Bzip2 compression to save space on the computer's hard disk.

Bzip2 is an open source data compression algorithm first released in 1996. It offers better file compression than older algorithms such as LZW and Deflate, but is slower as a trade off. Bzip2 is purely a file compressor. It does not have built-in archive facilities, but you can use bzip2 with an archive tool such as tar to compress multiple files. A bzip2 package is available from the Ubuntu package repository, for easy installation on Ubuntu Linux using the apt tool.

Step 1

Log in to the remote Ubuntu server through SSH, or open a terminal window if you are running the Ubuntu desktop.

Step 2

Type "sudo apt-get update" at the terminal prompt to update the local package list with the latest data from the repository. Enter your password when requested by the sudo command.

Step 3

Type "sudo apt-get install bzip2" to download and install the bzip2 package from the Ubuntu package repository. The required files are small, so installation is quick to complete.

Step 4

Type "bzip2 -c filename > compressed.bz2" to compress a file named "filename" into the compressed file "compressed.bz2."

Step 5

Type "bunzip2 compressed.bz2" to decompress the file named "compressed.bz2." The decompressed file has the same name as the compressed file without the ".bz2" extension.


Type "dpkg -s bzip2" at the terminal prompt to view information about the bzip2 package. Read the bzip manual to view the parameters accepted by bzip2 and its many features.

references & resources