A BZ2 file is a compressed file type for archiving large files using a Bzip2 algorithm. The algorithm provides higher compression rates while maintaining low decompression speeds.
Files with a .bz2 extension typically appear on Unix-like operating systems, but they can also be unzipped on Windows. Various utilities help extract the file's contents, and the process differs depending on the operating system.
This guide demonstrates how to unzip a BZ2 file on Linux/Unix and Windows using two methods.
- An unzipping utility or access to the command line/terminal.
- Sufficient disk space (see how to check disk space in Linux).
- Read and write permissions in the destination.
How to Unzip BZ2 Files on Linux and Unix
The sections below demonstrate both tool types.
Method 1: Using bzip2 and bunzip2 Command
bzip2 command compresses and decompresses BZ2 files. The tool comes preinstalled on Linux. If the command is not available on the system, install the bzip2 tool with the following:
sudo apt install bzip2
Note: Learn more on how to use Linux sudo command (with examples).
To extract a .bz2 file, open the terminal and run the following command and specify a file name:
bzip2 -d file.bz2
-d option performs decompression. The alias for the command and option is
bunzip2, so the following command does the same:
The original input .bz2 file disappears after running the command. To preserve the original file, add the
bzip2 -kd file.bz2
The file decompresses in the same directory and keeps the original compressed file.
Method 2: Using lbzip2 or lbunzip2 Command
The lbzip2 tool enables multi-threaded bz2 decompression. Multi-threaded decompression offers better performance when working with large files. If lbzip2 is not available by default, install it with the following command:
sudo apt install lbzip2
lbzip2 command with the
-d tag to switch to decompression mode. For example:
lbzip2 -d file.bz2
Alternatively, use the
The command automatically picks the number of threads. To specify the number of threads manually, use the
-n option and provide the number:
lbzip2 -d -n 16 file.bz2
The command sets sixteen threads for the decompression.
How to Unzip BZ2 Files on Windows
Although bz2 files primarily appear on Linux, there are Windows programs that can unzip the file type. There is no readily-available default program on Windows, but there are plenty of third-party solutions.
For example, the 7-Zip tool offers a command line tool and GUI program to unzip bz2 files. Additional tools, such as WinZip, WinRAR, or PeaZip, all support the .bz2 file format.
Method 1: Using CMD in Windows
To use the
7z command, do the following:
1. Open the command prompt.
2. Navigate to the .bz2 file.
3. Extract the file with the following command:
7z x file.bz2
Note: If the command is not found, add the 7-Zip installation folder to the PATH environment variable.
4. Choose whether to replace the existing file. The
7z command completes the extraction according to the provided answer.
Method 2: Using GUI in Windows
The 7-Zip tool provides a user-friendly GUI program to extract compressed files, including files in the .bz2 format. To extract a .bz2 file, open the 7-Zip program and do the following:
1. Navigate to the file location.
2. Select the file and choose Extract in the top menu.
3. A new window opens with extraction options. Choose the location and click the OK button to extract the .bz2 file.
4. The extraction process creates a new folder with the same name as the file.
Open the new folder to view the extracted file.
After reading this guide, you know what BZ2 files are and how to extract them on Linux and Windows. Archive files come in various formats, and the .bz2 format is excellent when working with large files.
Next, check out our article and learn how to unzip tar.bz2 files.