
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.






























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