How to Create a Gzip Archive in Linux

By | October 10, 2008

This post should be useful for those who haven’t used Linux for a long time. I am going to tell you how to create gzip 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.

2 thoughts on “How to Create a Gzip Archive in Linux

  1. nerak99

    tar -zcf filename.tar.gz folder_needing_zipping

    Will do the whole lot in one go

  2. nerak99

    tar -zcf filename.tar.gz folder_needing_zipping

    Will do the whole lot in one go

Comments are closed.