Linux


The zip utility

Zipping and Unzipping Files in Linux

Yesterday was the age of proprietary Operating systems and Softwares. Today, open source utilities can do all most all the tasks that yesterday’s properietary have done. And tomorrow is only for the linux and its free world !!

There are two utilities named, zip and unzip in linux to carry over the compression and extraction tasks. You have to install these first. For ubuntu/debian based destros use :

# apt-get install zip
# apt-get install unzip

If you are Red Hat Linux/Fedora user then you can use yum command to install zip and unzip :

# yum install zip
# yum install unzip

Let’s see how does ZIP work.

To create a zip file for all the files in the current directory named ‘test’, you can use the following command:

$ zip test *

The .zip extension will be added automatically and creates zip file named ‘test.zip’

To zip up an entire directory use :

$ zip -r test *

Working of UNZIP

To extract the archive named test.gz to the current directory use the following command:

$ unzip test.zip

You can also check the archieve for any corruption in data using the ‘tq’ arguement to unzip. If the achieve is fine, it will display a message as below:

# unzip -tq test.zip
No errors detected in compressed data of test.zip

To extract the file called info.php from test.zip,

$ unzip test.zip info.php

To extract all files to a specified directory, for eg: /study

$ unzip test.zip -d /study

Then, another useful one, to list all the files in a archieve without extracting it,
use the following -l argument.

$ unzip -l test.zip

Comments
  1. Steve says:

    Gud job buddy, useful tips !!

Leave a comment