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” o 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.