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:
Extract a File
Use the following command to extract the bz2 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:
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:
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:
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:
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 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.