How to Compress and Decompress Files on Linux

Windows Articles

How to install Oracle Java 15 on Ubuntu 20.04 / 18.04?

Hello, friends. We know that Java is one of the most popular programming languages and now it's version 15. So in this...

How to run the Linux Tail command in Windows 10.

Hi! The title of this post may seem incongruous, but it's not. In fact, for some time Microsoft has approached positions with...

How to compress large videos in Windows 10

Hello, how are you? Multimedia resources are definitely used in any system. Indeed, we live in the age of technology. That's why...

How to get Google Opinion Rewards in any Country

Greetings! Google Opinion Rewards is a cool app, which will allow you to earn credit, to spend it on the Google Play...

How to change the hostname on Ubuntu?

This simple tutorial will teach you how to change the hostname on Ubuntu. The steps we will tell you here will work...
Mel Khamlichi
Mel Khamlichihttp://www.osradar.com
Founder of Osradar, from Amsterdam Netherlands

Linux is really powerful platform loaded with strong compressing and decompressing mechanisms built-in. For Linux users, you may already have learned the name of .ZIP, .GZ, .TAR.GZ, .TGZ, .BZ2 etc. file types, right? These are different file compression methods and file types that Linux support by default. You can compress and decompress files into the formats on all the Linux distros.

Now, let’s take a look how to compress files into the following format.

Compressing files

  • ZIP

Zip is definitely one of the most popular compressed file formats. It’s widely used in all the platforms and really powerful for basic usage.

For compressing, ZIP uses the following structure:

zip {.zip-filename} {filename-to-compress}

If you want to compress a directory using ZIP, run this command:

zip -r {.zip-filename} {directory-to-compress}

In this example, I’m going to compress my Thunderbird profile. It’s also an awesome trick for backing up your Thunderbird profile.

zip -r thunderbird-backup.zip ~/.thunderbird

For decompressing the ZIP file, run this command:

unzip thunderbird-backup.zip
  • TAR

It’s a really powerful tool for compressing and decompressing the file(s) and directory. It’s more widely used as it offers more support for advanced compressing formats like TAR.BZ2. For compressing a file or directory using TAR command, follow the following structure:

tar -zcvf {.tgz-file} {files/directory} [using gzip compression method]
tar -jcvf {.tbz2-file} {files/directory} [using bz2 compression method]

For example, I’ll be compressing my “~/.thunderbird” directory. If you want to compress the file(s), just exchange the later part of the command.

tar -jcvf thunderbird-email-profile.tar.bz2 .thunderbird

For decompressing the file, run this command:

tar -xvf thunderbird-email-profile.tar.bz2

There’s also another file type called XZ. This one follows extreme compression method and used for compressing lots of small files into one, tight archive.

For turning into XZ archive, use the following command structure:

tar -cvJf filename.tar.xz /directory/*
  • GZIP & BZIP2

These tools also come pre-installed in most of the Linux distros. They’re not used as frequently as they lack the ability to compress directory. These are generally there for serving as the algorithm source for other software like TAR. However, you can still use them in the same way. The command line structure is quite same.

gzip {filename}
bzip2 {filename}

For decompressing a compressed file, use the following commands:

bzip2 -d {.bz2-file}
gzip -d {.gz file}

Voila! Enjoy the powerful compression feature of Linux!

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to install Oracle Java 15 on Ubuntu 20.04 / 18.04?

Hello, friends. We know that Java is one of the most popular programming languages and now it's version 15. So in this...

How to run the Linux Tail command in Windows 10.

Hi! The title of this post may seem incongruous, but it's not. In fact, for some time Microsoft has approached positions with...

How to compress large videos in Windows 10

Hello, how are you? Multimedia resources are definitely used in any system. Indeed, we live in the age of technology. That's why...

How to get Google Opinion Rewards in any Country

Greetings! Google Opinion Rewards is a cool app, which will allow you to earn credit, to spend it on the Google Play...

How to change the hostname on Ubuntu?

This simple tutorial will teach you how to change the hostname on Ubuntu. The steps we will tell you here will work...
x