In this post I’ll describe the process of creating a tar.gz archive in linux. It is a common practice to create backups or transfer files between servers using such archives. It is quite easy to create them and I’ll show you how to do it.
First of all you need to create a tarball – an archive that contains all the files, that are not compressed. Tar archive file size is the same as the sum of file sizes of the files that are located in the archive. In order to create it, you should issue the following command:
tar -cf <name of the archive>.tar <files of folders that will be in the archive separated by space>
This command will create a tar file. Next you need to compress it. The fastest way to do it in Linux is to use gzip compression (bzip2 often offers better results, but it takes much time and I won’t describe it here). In order to do it just input the following:
gzip <name of the archive created>.tar
This will compress your tarball and will delete your tar archive. The only thing that will be left is tar.gz archive. This is what you need. You can compare file sizes to find, how much space and bandwidth you have won by using the compressed version of your files.