Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

unzip bz2
bz2

Unzip bz2

Educative Answers Team

File compression is done all across the world – it significantly decreases the size of file(s) through various forms of encoding. Decompression refers to restoring the original contents of the file.

There are several file compression and decompression tools available in Linux such as gzip, 7-zip, Lrzip, PeaZip, etc.

Using bzip2

We will look at how to compress and decompress .bz2 files using the bzip2 tool in Ubuntu Linux.

Bzip2 is a well known compression tool that is available on most, if not all, of the major Linux distributions. You can use the appropriate command for your distribution to install it.

Steps

  1. Use the following command to install the relevant library.
sudo apt-get install bzip2
  1. Now, open the directory that contains the relevant file. For example, if the file is in “Documents” folder, write the following command. This will open the relevant directory.
cd Documents
  1. Next, write the following command in terminal. The filename is basically the name of your file.
bzip2 -z filename
  1. By default, the input files are deleted; however, in order to keep an input file, write the following command.
bzip2 -zk filename

Using tar xjf

For files that have the extension of .tar.bz2, use the method below. In this example, our file is in the “Documents” folder and has the name “Myfile.tar.bz2” – we need to unzip this file.

Steps

  1. Open the directory that contains the relevant file. In our case, the file is in the “Documents” folder.
cd Documents

Always write ls to view the list of files that are present in the directory.

  1. Next, in order to unzip, write the following command in terminal.
tar xjf Myfile.tar.bz2

Now you can go to your “Documents” folder and verify that the file has been unzipped. You can see there will be a new unzipped file with the same name, but without the extension of .tar.bz2.

1 of 2

RELATED TAGS

unzip bz2
bz2
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring