Zip Tar Gzip on Linux

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 Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.