Wednesday 25 October 2017

How to Tar and Gzip a directory

TAR is short for Tape Archive and is often refereed to as a tarball. Think of it as a Windows zip file without the compression.

GZIP is short for GNU Zip. It is used to compress a single file on the Linux platform.

Together, you can TAR a folder into a single file and then reduce the size of the file with Gzip. This makes it easy to transfer around a network or upload it somewhere else. 

1) Navigate to the folder which contains the directory.
2) Run the following command:

tar -zcvf new-archive-name.tar.gz directory_name

new-archive-name.tar.gz can be anything providing it ends in tar.gz

directory_name is the name of the directory you are trying to compress. If I wanted to TAR and Gzip the /tmp/ folder, I would run:

tar -zcvf TempFiles.tar.gz /tmp

No comments:

Post a Comment