Linux Basics: Untarring And Unzipping File Archives

May 26th, 2008 · No Comments

Two of the most popular file compression formats on Linux are TAR and ZIP. You might have seen some file archives with the .tar.gz extension. Those are TAR archives. On the other end, zipped files are well known as they also exist on other operating systems such as Microsoft Windows.

Using TAR To Compress Or Extract Files

TAR means Tape Archive. While it doesn’t need to be stored on a tape backup anymore, TAR is used to create an uncompressed file archive. In order to compress a TAR file, the gzip compression format is used.

To make a TAR archive from the command line, the syntax is:

tar cvzf [archive name].tar.gz [directory to archive]

So for example if you wanted to create a compressed archive from a folder named “documents”, you would type:

tar cvzf documents.tar.gz documents

To extract files from a “targzipped” archive, the syntax is:

tar xvzf [archive].tar.gz

So if you wanted to extract the content from an archive file named documents.tar.gz, you would type:

tar xvzf documents.tar.gz

Let’s look at the switches used here:

  • C: Create archive
  • X: Extract files from archive
  • V: Verbose output
  • Z: Enable GZIP compression
  • F: Specify which file(s) to process

Using Zip

Compressing or extracting files in ZIP format is pretty easy. Here’s how to compress multiple files using the ZIP command:

zip [archive].zip file1 [file2 file3...]

So for example, if you wanted to create a zipped archive containing two documents, you would use:

zip documents.zip mytext.doc othertext.pdf

Unzipping a zipped archive is quite easy too:

unzip [archive].zip

There are some switches you can use with the zip command. Typing

man zip

will bring up the zip manual.

Other Compression Formats

There some other compression formats and utility available. Here are a few:

  • bzip2
  • compress / uncompress
  • cpio
  • zoo

They are just not as popular as the previous format. Have a look at their manpages to find out more.

0 responses so far ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment




Posted in Linux · Tutorials | No Comments

Dedicated Servers
 
VPS
Website Hosting
 

Recent Comments

Recent Webmasters

Hosting Type :
Monthly Price :
Storage :
Transfer :
Sort By :
Search