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.
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.
sudo apt-get install bzip2
cd Documents
bzip2 -z filename
bzip2 -zk filename
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.
cd Documents
Always write
ls
to view the list of files that are present in the directory.
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
.
RELATED TAGS
View all Courses