Under Slackware Linux, there are several programs that can be used to
compress and archive files. These programs are especially useful for making
backups and sending copies of files between machines over a network
connection. There are programs for dealing with
Unix formatted archives, as well
as Windows archives.
gzip(1) is the GNU compression program. It takes a single
file and compresses it. The basic usage is as follows:
The resulting file will be named infile.gz and will
usually be smaller than the input file. Note that infile.gz will replace infile. This means that
infile will no longer exist, even though a gzipped copy
will. Regular text files will compress nicely, while jpeg images, mp3s, and
other such files will not compress too well as they are already compressed.
This basic usage is a balance of final file size and compression time. The
maximum compression can be achieved like so:
This will take a longer time to compress the file, but the result will be
as small as gzip can make it. Using lower values for
the command line option will cause it to compress faster, but the file will
not be as compressed.
Decompressing gzipped files can be done using two commands, which are really
just the same program. gzip will decompress any file
with a recognized file extension. A recognized extension can be any of the
following: .gz, -gz,
.z, -z, .Z, or
-Z. The first method is to call
gunzip(1) on a file, like so:
This will leave a decompressed version of infile in the
current directory, and the .gz extension will be stripped from the filename.
The other way to decompress a gzipped file is to call gzip
on the file:
This will cause exactly the same behavior as calling gunzip. The reason for
this is simple: gunzip is simply a symbolic link to
/bin/gzip:
$ cd /usr/bin
$ ls -l gunzip
lrwxrwxrwx 1 root root 9 Feb 2 09:45 gunzip -> /bin/gzip |
So, running gunzip is really just running
gzip with a different name. The program can determine
how it is being called and take action appropriately. In this case,
gzip will know that it is being called as
gunzip and decompress the file. Therefore, you can use
gzip or gunzip to decompress any
gzipped file.