Archive

Posts Tagged ‘create tar archive linux’

How to Create a Gzip Archive in Linux

October 10th, 2008 1 comment

This post should be useful for those who haven’t used Linux for a long time. I am going to tell you how to archives in linux. That’s greatly useful when you’re creating some backups, or anything for download, especially if your Internet is quite slow. So, let’s start…

Gzip archives are often used with tar files. Tar files are archives too, but they don’t enable any compression. Gzip allows you to lower the size of a tar archive and it is recommended to use the combination. So, first of all, we need to create a tar archive of anything you like. As we’re usually dealing with directories, let’s create an archive of a directory.

We will create an archive of  wp-content folder. In order to do this, let’s type

tar -cf content.tar wp-content

where content.tar is the resulting filename of a tar archive. Your server will think some time and then content.tar will appear in our folder.

Now we need to gzip it. Please, pay attention to the file size on the screenshot below.

And now the final operation is to gzip the file with the following command:

gzip content.tar

This will compress our tar archive without any messages too.

Let’s pay attention to the size: the file is now compressed and ready for download. We’ve created an archive of a folder, just like using Winrar or any archiver in Microsoft Windows. Was that easy? I think there were no difficulties while doing this.

I will tell you how to extract files from the archive if you ask me about this. Please, leave comments and ask anything you want.

How to Create an Archive in Linux

May 30th, 2008 No comments

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.