Packing - unpacking.


The most common compression programme for Linux is called tar. Although tar is not the only "packer" around it would have to count as the most popular, used either on its own, or in conjunction with another programme like gzip. A tar compressed file is commonly called a tarball, & has a file ending .tar. When tar is used with gzip it is basically a file that has been compressed with tar & then further compressed with gzip, & would have the file ending in .tar.gz or .tgz. Both of these common compression programmes can be used independently, but due to the combined effect of producing a very small file, they are often used together. Take a look at the man pages for both of these binaries (programmes) to see how powerful & flexible they are.

Lets take the unpacking example first as you'll probably have a file lying round that you want to try out. Tar is used to both pack & unpack a file whereas gzip is only used to compress, & gunzip is used to unpack. Unpacking a file called test.gz is as simple as typing gunzip test.gz in the directory where test.gz is saved. If the test file has been tarred & zipped (test.tar.gz) then there are two steps that have to be carried out. First the file has to be unzipped, gunzip test.tar.gz , then we have to "untar" the resulting file. Our test file will now be called test.tar after it has been unzipped, & we can unpack it by typing tar -xvf test.tar . The options -xvf mean extract(x) the file(f) in a verbose(v) fashion, i.e. display what is happening on your monitor. If the file was called test.tgz then the correct command would be tar -xvfz test.tgz , the only difference here being the addition of the -z option meaning unzip.

Packing files into a .tar or .gz file is relatively simple, even though there are many more options that are available to you. For the following comparisons we will use the following directories & files: /home/user & test.file.

Take the gzip compression first. Simply by typing gzip /home/user/test.file & the test.file will be packed into test.file.gz. You can also use the -r option & gzip will recursively compress all files within the given directory.

Tar, on the other hand is a very powerful compression tool & has very many options. To tar our test.file just type
tar -cvf test.file.tar /home/user/test.file
The -c option = create tar file. Take a look at the tar manpages for a better look at what tar can do.



back a page    back to main index    forward a page
copyright 2001 Rob Hawke.
rob@highasakite.net