Tar.gz - A Quick and Easy Compression and Extraction Command Line

What I am going to do next is to introduce a very simple, quick and easy way of compression (zipping) and decompression (extracting) files using command line. This may be relatively easy to many users, especially to Linux experts. However, not everyone is an expert in that sense.

Learning to use command line to archive files can be a very beneficial. First of all, it does not use Graphical User Interface (GUI), therefore there is more resources made available for your systems (instead of using them on GUIs). Secondly, you are able to access remote systems using Secure Shell (SSH) connections and perform tasks on the remote systems, as though they are directly on your systems; that is, for example accessing web hosting servers via SSH to backup your web sites (although I know backup functions do exist in cPanel). Well, the list may still continue, but I shall stop here.

(learn more by clicking here...)

Creating An Archive

Assume you are on a text console, and you would like to zip up a folder at your current directory say "abcfolder", simply run the following command:

tar czvf myfolder.tar.gz abcfolder/

The above command creates an archive file name, myfolder.tar.gz. Everything under the directory abcfolder/ will be compressed and stored.

To compress all the files within a folder:

tar czvf allmyfiles.tar.gz *

The above command thus compresses all the files (including subfolders) within the directory and archived it as allmyfiles.tar.gz.

Basically, there are various variants you can play around with tar command in Linux. All you need is to type "man tar" to find out more information. So next, let's extract these files.

Extracting Files from Archive

Extracting is probably quite easy. If you have a .tar.gz file, simply type the command to extract all the files and folders to the current folder you are in.

tar -zxvf extractme.tar.gz

The above command extracts the archive, extractme.tar.gz to your current folder or directory.

So, you see, it's not really that difficult to use compress and uncompress files and folders in linux via command line. It's time to throw away some of GUIs.


Just wanted to say thank you for a well written article, it helped me to find a quick, clear answer to my question.

Michael J. Tinsley (not verified) | Tue, 2008-05-27 06:14

Thanks alot... it helped me very well since i was googling and ur post was the first to get useful info from..
thanks again

CFusion (not verified) | Fri, 2008-05-30 02:24

thank u very much...its quite helpful

sankar (not verified) | Wed, 2008-06-04 14:42

This popped up first on google, and did the trick. Thanks for the quick easy to find answer!

Guest (not verified) | Mon, 2008-06-16 14:53

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Use <!--pagebreak--> to create page breaks.
More information about formatting options

Syndicate, Bookmark & Sitemap

Syndicate Content Bookmark This Site NeoHide SiteMap

Quick Search

User login

Search

Sponsored Ads

Women's Corner

Who's new

  • troymanning
  • evenworld
  • brandontylerrussell
  • mgroup
  • ikonner

Syndicate

Syndicate content

FastBox Ad Feed

Subscribe Feeds

Feed Icon
Google
Yahoo!
Bloglines
Newsgator
MSN
Feedster
AOL
Furl
Rojo
Newsburst
Pluck
FeedFeeds
Add Kinja
SoloSub
MultiRSS
rMail
RSSFwd
Blogarithm
Eskobo
GritWire
BotABlog
Monitor This
Simplify