6 C
Amsterdam
Friday, December 4, 2020

How to Compress and Decompress Files on Linux

Must read

How To Configure Slave BIND DNS Server On Ubuntu 20.04

In our previous guide we covered the setup of Master(Primary) DNS Server. Here we'll learn that how to configure slave bind dns server on...

Install Fossil on Linux – An alternative to Git

Hello, friends. In this post, we will talk about a serious alternative to Git. In a few words, we'll show you how to install...

How to backup and restore BCD in Windows 10

Hi! Boot Configuration Data (BCD) is a set of data where the system boot information is stored. In addition, from there the operating systems...

How To Install and Configure Master BIND DNS Server On Ubuntu 20.04

Today we are going to learn that how to install and configure Master BIND DNS server on Ubuntu 20.04. As you all know that...
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 Configure Slave BIND DNS Server On Ubuntu 20.04

In our previous guide we covered the setup of Master(Primary) DNS Server. Here we'll learn that how to configure slave bind dns server on...

Install Fossil on Linux – An alternative to Git

Hello, friends. In this post, we will talk about a serious alternative to Git. In a few words, we'll show you how to install...

How to backup and restore BCD in Windows 10

Hi! Boot Configuration Data (BCD) is a set of data where the system boot information is stored. In addition, from there the operating systems...

How To Install and Configure Master BIND DNS Server On Ubuntu 20.04

Today we are going to learn that how to install and configure Master BIND DNS server on Ubuntu 20.04. As you all know that...

Diskpart is a very useful tool for managing storage in Windows 10.

Hello! Diskpart is an internal tool included in Windows systems that allows you to manage storage units. Indeed, it is possible to manage internal...
x