Skip to Content

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

warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, '_translation_tab_access' was given in /home1/extraris/public_html/neohide/includes/menu.inc on line 452.
Posted in

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.

Thanks

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

I used this info

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

thank u very much...its

thank u very much...its quite helpful

Thank you

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

Simple, Thanks...

I wish all articles could be as simple to the point as this one was, thanks!

Just What I Need

Thank you

thanks

nice one, just what i needed :)

thanks it is a useful simple

thanks

it is a useful simple and concise guide

Thank you

Thank you

Thanks

Nice article for beginners

thanks

very very helpful
the other sites all go roundabout the main point

Great! Thanks for

Great! Thanks for information!

++ great

Cool article. bum question but :Can you compress a uncompressed tar to a gzip tar.gz without expanding the .tar file? i have limited hdd space for this operation

Help

Thanks, That was quite helpful. Kindly make this description a bit brief.

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.

More information about formatting options