Zip Tar Gzip on Linux

Number of Views : 15314

I often asked questions regarding Linux. Yesterday I was asked how to unzip a file. An individual new to Linux received a .zip file and was unable unzip it. They were using a terminal window.

Zip / Unzip

I believe that zip is common to most all distributions. It does not do the best job of compression but it works. To unzip a file from a command line in Linux you use

unzip ZIPFILENAME.zip

To Zip a file you only need to reverse that command

 zip -r YOURNEWZIPFILE.zip directory_to_zip

Tar

Tar stands for “Tape ARchive” it was used for backing up to tape. If you are a frequent Linux user you will have seen a .tar file. Tar is quick an dirty. It does not have the best compression but it is fast.

To un-tar or extract a tar file

tar -xvf TARFILENAME.tar

To Tar a directory or file

 tar -cvf TARFILENAME.tar.gz directory-name

GZ or Tar.GZ

This is probably the most common file type you will see when using Linux. This does very good compression and is quick.

To untar and un-gzip (decompress) a file

tar -zxvf TARFILENAME.tar.gz

To Compression and Tar gzip a directory

tar -zcvf NEWTARFILENAME.tar.gz directory-name

The switches in the call:

  • -z: Compress archive using gzip program
  • -c: Create archive
  • -v: Verbose this will display progress to the terminal
  • -f: Archive File name

Leave a Reply

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