How do I compress/zip a whole Linux directory?

Posted under » Linux on 22 Feb 2012

You need to use the tar command as follows (syntax of tar command):

tar -zcvf archive-name.tar.gz directory-name
tar -zcvf /tmp/archive-name.tar.gz directory-name

Above command will create an archive file called "archive-name.tar.gz" in current directory or you can save it on the /tmp/ folder. If you specify a nested directory location, the archive will also have that information. I would prefer to use a relative name and not the full path name.

Where,

If you wish to restore your archive then you need to use the following command. It will extract all files in current directory.

$ tar -zxvf myforntarchive.tar.gz

Note the difference where -x: Extract files from given archive.

 

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS data