Previous Next Contents

10. Useful Programs

10.1 Archiving: tar & gzip

Under Unix there are some widely used applications to archive and compress files. tar is used to make archives, that is collections of files. To make a new archive:

$ tar -cvf <archive_name.tar> <file> [file...]

To extract files from an archive:

$ tar -xpvf <archive_name.tar> [file...]

To list the contents of an archive:

$ tar -tf <archive_name.tar> | less

Files can be compressed to save disk space using compress, which is obsolete and shouldn't be used any more, or gzip:

$ compress <file>
$ gzip <file>

that creates a compressed file with extension .Z (compress) or .gz (gzip). These programs don't make archives, but compress files individually. To decompress, use:

$ compress -d <file.Z>
$ gzip -d <file.gz>

RMP.

The unarj, zip and unzip utilities are also available. Files with extension .tar.gz or .tgz (archived with tar, then compressed with gzip) are very common in the Unix world. Here's how to list the contents of a .tar.gz archive:

$ gzip -dc <file.tar.gz> | tar tf - | less

To extract the files from a .tar.gz archive:

$ gzip -dc <file.tar.gz> | tar xvf -


Previous Next Contents