Linux Commands

How to Open bz2 File?

As a little introduction, the bz2 File is the compressed version of a normal file that helps a user decrease its size.  So, commands like “Tar”, which is used to create or extract the tar archives, also support a huge range of comparison programs like lzop, xz gzip, bzip2, lzip, lzma, etc. Bzip2 is one of the best algorithms to compress tar files, and by convention, a tar archive’s name compressed with the bzip2 ends with .tar.bz2 or .tbz2. We will cover brief information on ways to open bz2 file Linux easily.

How to Open bz2 File Linux?

Now, we will consider the complete procedure from compressing to extracting the bz2 file in Linux.

Use bzip2 Command:

Compress a File

First, compress the file through the bzip2 command, so open the terminal and execute the following command:

$ bzip2 myfile.txt   # Compress a File

Extract a File

Use the following command to extract the bz2 file:

$ bzip2 -d myfile.txt.bz2   # Uncompress a file

Use tar Command:

Most of the Linux OS has pre-installed tar utility, so for extracting a tar.bz2 file, you can use this command:

$ tar -xf archive.tar.bz2

In the above command, -x works for extracting and -f works as the archive file’s name.  After executing the command, the system starts to detect the compression type, then extract the archive.  You can use this command for extracting the tar archives, which are compressed with different algorithms like .tar.xz. In case you want verbose output, use the following command:

$ tar -xvf archive.tar.bz2

In this command line, -v is added as verbose to have wordy output. This command provides information to tar for displaying the file names that are being extracted.

Extract a Specific File from the Tar.bz2 File

You can use the below command for extracting a specific file:

$ tar -xf archive.tar.bz2 file1 file2

Once you execute the command, the system will detect the file’s paths to extract it.

Listing tar.bz2 File

You can easily list the content of tar.bz2 files by executing the command given below:

$ tar -tf archive.tar.bz2

Once you execute the command in the terminal, your output will look like this:




In case you want to see more information as an output, then you can use verbose, that means -v option for it.

-rw-r--r-- linux/users 0 2021-03-15 03:10 file1

-rw-r--r-- linux/users 0 2021-03-15 03:10 file2

-rw-r--r-- linux/users 0 2021-03-15 03:10 file3


This wraps the complete details on the bz2 file and how one can easily extract it using various ways in Linux. As we have mentioned earlier, it is good to compress the file because of its reduced file size. We have described multiple procedures that can help you compress, extract, and open bz2 files in Linux without having any issues.

About the author

Simran Kaur

Simran works as a technical writer. The graduate in MS Computer Science from the well known CS hub, aka Silicon Valley, is also an editor of the website. She enjoys writing about any tech topic, including programming, algorithms, cloud, data science, and AI. Travelling, sketching, and gardening are the hobbies that interest her.