15.2. Decompression

15.2.1. tar.gz archive

The standard[1] compression format under Unix systems is the gzip format, developed by the GNU project, and considered as one of the best general compression tools.

gzip is often associated with a utility named tar. tar is a survivor of antediluvian times, when computerists stored their data on tapes. Nowadays, floppy disks and CDROM have replaced tapes, but tar is still being used to create archives. All the files in a directory can be appended in a single file for instance. This file can then be easily compressed with gzip.

This is the reason why much free software is available as tar archives, compressed with gzip. So, their extensions are .tar.gz (or also .tgz to shorten).

15.2.2. The use of GNU Tar

To decompress this archive, gzip and then tar can be used. But the GNU version of tar (gtar) allows to use gzip "on-the-fly", and to uncompress an archive file without hardly noticing it (and without the need for the extra disk space).

The use of tar follows this format:

tar <file options> <.tar.gz file> [files] 

The <files> option is not required. If it is omitted, processing will be made on the whole archive. This argument does not need to be specified to extract the contents of a .tar.gz archive.

For instance:

$ tar xvfz guile-1.3.tar.gz
-rw-r--r-- 442/1002      10555 1998-10-20 07:31 guile-1.3/Makefile.in
-rw-rw-rw- 442/1002       6668 1998-10-20 06:59 guile-1.3/README
-rw-rw-rw- 442/1002       2283 1998-02-01 22:05 guile-1.3/AUTHORS
-rw-rw-rw- 442/1002      17989 1997-05-27 00:36 guile-1.3/COPYING
-rw-rw-rw- 442/1002      28545 1998-10-20 07:05 guile-1.3/ChangeLog
-rw-rw-rw- 442/1002       9364 1997-10-25 08:34 guile-1.3/INSTALL
-rw-rw-rw- 442/1002       1223 1998-10-20 06:34 guile-1.3/Makefile.am
-rw-rw-rw- 442/1002      98432 1998-10-20 07:30 guile-1.3/NEWS
-rw-rw-rw- 442/1002       1388 1998-10-20 06:19 guile-1.3/THANKS
-rw-rw-rw- 442/1002       1151 1998-08-16 21:45 guile-1.3/TODO
...

Among the options of tar:

tar allows you to perform several actions on an archive (extract, read, create, add...). An option defines which action is used:

15.2.3. bzip2

A compression format named bzip2 has begun to replace gzip in general use. bzip2 produces smaller archives than gzip does, but is not yet a standard. Only recently can .tar.bz2 extensions can be found.

bzip2 is used like gzip by means of the tar command. The only thing to do is to replace the letter z by the letter y. For instance:

$ tar xvfy foo.tar.bz2

Some distributions use or used to use the option I instead:

$ tar xvfI foo.tar.bz2

Another way (which seems to be more portable, but is longer to type!):

$ tar --use-compress-program=bzip2 -xvf foo.tar.bz2

bzip2 must be installed and included in your PATH environment variable before you run tar.

15.2.4. Just do it!

15.2.4.1. The easiest way

Now that you are ready to uncompress the archive, do not forget to do it as administrator (root). You will need to do things that a single user is not allowed to do, and even if you can perform some of them as a regular user, it is simpler to just be root the whole time.

The first step is to be in the /usr/local/src directory and copy the archive there. You should then always be able to find the archive if you lose the installed software. If you do not have a lot of space on your disk, save the archive on a floppy disk after having installed the software. You can also delete it but be sure that you can find it on the Web whenever you need it.

Normally, decompressing a tar archive should create a new directory (you can check that beforehand thanks to the t option). Go then in that directory, you are now ready to proceed further.

15.2.4.2. The safest way

Unix systems (of which GNU/Linux and FreeBSD are examples) can be secure systems. That means that normal users cannot perform operations that may endanger the system (format a disk, for instance) or alter other users' files. It also immunizes the system against viruses.

On the other hand, root can do everything - even running a malicious program. Having the source code available allows you to examine it for malicious code (viruses or Trojans). It is better to be cautious in this regard[2].

The idea is to create a user dedicated to administration (free or admin for example) by using the adduser command. This user must be allowed to write in the following directories: /usr/local/src, /usr/local/bin and /usr/local/lib, as well as all the sub-tree of /usr/man (he also may need to be able to copy files elsewhere). I recommend that you make this user owner of the necessary directories or create a group for him and make the directories writable for the group.

Once these precautions are taken, you can follow the instructions in the section The easiest way.

Notes

[1]

More and more a new program, called bzip2, more efficient on text files (and requiring more computing power) is being used. See the later section bzip2 that deals specifically with that.

[2]

A proverb from the BSD world says: "Never trust a package you don't have the sources for."


Tux on Star from MandrakeSoft Linux is a registered trademark of Linus Torvalds. All other trademarks and copyrights are the property of their respective owners.
Unless otherwise stated, all the content of these pages and all images are Copyright MandrakeSoft S.A. and MandrakeSoft Inc. 2000.
http://www.linux-mandrake.com/