
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.
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
Submitted by Michael J. Tinsley (not verified) on Tue, 2008-05-27 06:14.
- reply
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
Submitted by CFusion (not verified) on Fri, 2008-05-30 02:24.
- reply
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
Submitted by sankar (not verified) on Wed, 2008-06-04 14:42.
- reply
thank u very much...its quite helpful
Thank you
Submitted by Guest (not verified) on Mon, 2008-06-16 14:53.
- reply
This popped up first on google, and did the trick. Thanks for the quick easy to find answer!
Simple, Thanks...
Submitted by Guest (not verified) on Fri, 2008-08-08 20:49.
- reply
I wish all articles could be as simple to the point as this one was, thanks!
Just What I Need
Submitted by aespe (not verified) on Wed, 2008-09-17 09:35.
- reply
Thank you
thanks
Submitted by olly (not verified) on Tue, 2008-12-16 11:16.
- reply
nice one, just what i needed :)
thanks it is a useful simple
Submitted by Guest (not verified) on Sat, 2009-01-03 10:14.
- reply
thanks
it is a useful simple and concise guide
Thank you
Submitted by Guest (not verified) on Fri, 2009-01-09 18:17.
- reply
Thank you
Thanks
Submitted by Joby (not verified) on Tue, 2009-07-21 13:57.
- reply
Nice article for beginners
thanks
Submitted by urmish (not verified) on Mon, 2009-11-16 19:31.
- reply
very very helpful
the other sites all go roundabout the main point
Great! Thanks for
Submitted by Ann55 (not verified) on Fri, 2009-11-27 08:06.
- reply
Great! Thanks for information!
++ great
Submitted by cagerage (not verified) on Wed, 2009-12-02 03:32.
- reply
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
Submitted by Farid Yar Khan (not verified) on Fri, 2010-05-28 15:21.
- reply
Thanks, That was quite helpful. Kindly make this description a bit brief.
Post new comment