HOW TO COMPRESS AND DECOMPRESS FILES IN LINUX: bzip2 and bunzip2

By | July 18, 2016

COMPRESSING and decompressing files are now normal activities a computer user engages in from time to time. Especially now that there are increase in the amount and frequencies with which information is being shared around the world, in various formats and mostly large in size. And the internet have proven to be a very reliable medium to share e these files. This result in the need for files to be compressed into smaller sizes to reduce time and internet data (bandwidth) required to upload such files and also the need for the end-users to that downloads it to be able to decompress the files into usable formats. In short this is how most software packages are uploaded and downloaded nowadays. So a good knowledge of how to do this would be necessary.

In a Linux graphical user interface (GUI) there are some built-in features in most Linux distribution and third-party free softwares available out there used to compress and decompress. But in this series of posts I would focus on how it can be done over the command-line (shell) and then finally on the GUI.

Linux includes several composition utilities that can be used to create, compress, expand or list the content of compressed files and archives. Linux include several compression utilities that you can use to create, compress, expand, or list the content of compressed files and archives (archiving). Among all we would be using the Bunzip2 and Bzip2 compression package in this post and in subsequent posts I would deal with the Gunzip2/Gzip and Tar packages

Bzip2 is used to compressed files while bunzip2 is used to do the reverse (i.e. decompress). It is mostly used with regards to files and not directories. It is used in this format;

bzip2 file
bzip2 picture.jpg
bzip2 memo.txt

When these commands above are entered, the file would be formed with a ‘.bz2’ file extension. (e.g. picture.jpg.bz2). you can also use the bzip2 command to compress multi0ple files;

bzip2 file1 file2 file3

The 3 files would become file1.bz2, file2.bz2 and file3.bz2 respectively.

Now to reverse (decompress) these the bunzip2 command utility is used. It follows a similar format like bzip2;

bunzip2 compressed_file.bz2
bunzip2 picture.jpg.bz2

Decompress multiple files using;

bunzip2 pic1.jpg.bz2 pic2.jpg.bz pic3.jpg.bz2

Yeah another simple command line tool, play around with it a little.

Happy Linux’NG!


NEVER MISS AN UPDATE




I agree to have my personal information transfered to MailChimp ( more information )

Join over 10,000 visitors to receive Open Source tips, trick, news, tutorials, programming and more.

We hate spam. Your email address will not be sold or shared with anyone else.

ALEXANDER OMOROKUNWA
MUST READ  How to Install Synaptic Package Manager in Ubuntu Linux

Tell us what you think