How to Compress file/folder in Linux

Introduction

A backup, or the process of backing up, refers to the copying and archiving of computer data so it may be used to restore the original after a data loss event. The verb form is to back up in two words, whereas the noun is backup. Backups have two distinct purposes.

  • The primary purpose is to recover data after its loss, be it by data deletion or corruption.
  • Data loss can be a common experience of computer users.

Following are the methods through which we can compress the file and folders.

1) ZIP a file/folder

#zip file.zip file1 file2
#zip file.zip dir1
#zip -option file.zip dir1

How to zip a file with excluding file/folder

zip -r conference_01-01-2015_14-30.zip /var/www/conference/* -x home_backup/

2) TAR a file/folder

tar -cvf /backup/etc.tar /etc/*
tar -cvf /backup/etc.tar

3) GZIP a file/folder

gzip is the preferred compression tool for Linux. To compress the tar file using gzip, following is the command:

gzip etc.tar

To decompress the tar file using gzip, following is the command:

gzip -d etc.tar.gz

4) BZIP2 a file/folder

There is also another tool that is rapidly gaining acceptance in the Linux world: bzip2. This is supposed to become the official way of doing it in the near future, so it may be a good idea to get to know ‘bzip2’
To compress the tar file using bzip2, following is the command:

bzip2 etc.tar

To decompress the tar file using bzip2, following is the command:

bzip2 -d etc.tar.bz2
19 replies
  1. where to watch
    where to watch says:

    Hi there, just became aware of your blog through Google, and
    found that it is truly informative. I’m going to
    watch out for brussels. I will be grateful if you continue this in future.
    Numerous people will be benefited from your writing.
    Cheers!

    Reply
  2. assignment help australia
    assignment help australia says:

    Definitely imagine that which you said. Your favorite reason appeared to be on the net the simplest factor
    to be mindful of. I say to you, I definitely get irked even as people think about worries that they plainly don’t understand about.
    You controlled to hit the nail upon the top as smartly as
    outlined out the entire thing with no need side effect ,
    other folks can take a signal. Will likely be again to get more.
    Thank you

    Reply
  3. essay helper
    essay helper says:

    I have been surfing online more than 3 hours today, yet
    I never found any interesting article like yours. It’s pretty worth enough for me.
    In my opinion, if all website owners and bloggers made good content as you did, the net will be much more useful
    than ever before.

    Reply
  4. how to socialize a puppy
    how to socialize a puppy says:

    hello there and thank you for your information ?
    I?ve definitely picked up anything nnew from right here.
    I did however expertise a ffew technical points using this web site, since I experienced
    to reload the website a lot of times previous to I could get it too load properly.

    I had been wondering if your web host is OK? Not that I’m complaining, but slow loading
    instances timmes will very frequently affect your placement in googlee andd could damage your high-quality
    score if ads and markeing with Adwords. Well I
    am adding this RSS to myy e-mail and can look out for muxh more of your respective fascinating content.

    Ensure that you update this again soon..

    Reply
  5. Booth Event
    Booth Event says:

    Greetings! This is my first visit to your blog! We are a team of volunteers and
    starting a new project in a community in the same niche. Your
    blog provided us useful information to work on. You have done a wonderful
    job!

    Reply
  6. Ezra
    Ezra says:

    I’ve read several excellent stuff here. Certainly value bookmarking
    for revisiting. I wonder how much attempt you put to create this kind
    of wonderful informative web site.

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *