gzip produces files with a
gunzip can decompress files created by gzip, compress or
pack. The detection of the input format is automatic.
The format of the
.gz files generated by gzip is
described in RFCs (Request For Comments)
and 1952. Some additional information on the gzip format is
A brief description of the compression and decompression
algorithms used by gzip is given here.
A more informal introduction written by Antaeus Feldspar is given
If you have a question about gzip, look first for an answer in this page. If you don't find it, write to firstname.lastname@example.org . Please give as much information as possible, at least the name of your operating system (Windows XP, Linux...), the exact command that you typed and the exact error messages that you get. If you just say "gzip doesn't work" I cannot provide any help.
To extract gzip-1.2.4.tar and compile the sources on Unix systems, do:
tar xvf gzip-1.2.4.tar cd gzip-1.2.4 ./configure make
.tar.gz files on
Windows 9x/NT/2000/ME/XP use
PowerArchiver 6.1 (freeware) or
7-zip (freeware) or
tar on MSDOS or other systems, see the
FAQ of the
On several systems, compiler bugs cause gzip to fail, in
particular when optimization options are on. See the section "Special
targets" at the end of the INSTALL file for a list of known problems.
For all machines, use
make check to check that
gzip was compiled correctly. Try compiling gzip without
any optimization if you have a problem.
The gzip user manual is available here.
Executables for various systems are available here:
For Linux or BeOS, gzip is already on your system.
tar.Z files on Unix systems, do:
zcat file.tar.Z | tar xvf -
99.9% of the problems with gzip are due to file transfers done in ASCII mode instead of BINARY mode. In particular, gopher is known to corrupt binary files by considering them as ASCII. Make sure that your local copy of the file has exactly the same byte size as the original.
If you have transferred a file in ASCII mode and you no longer have
access to the original, you can try the program fixgz
to remove the extra CR (carriage return) bytes inserted by the
transfer. A Windows 9x/NT/2000/ME/XP binary is here.
But there is absolutely no guarantee that this will actually
fix your file. Conclusion: never transfer binary files in ASCII mode.
fixgz and run it, do:
cc -o fixgz fixgz.c fixgz bad.gz fixed.gz gzip -tv fixed.gz
This is the same problem as above: a transfer not made in binary mode has corrupted the gzip header, thus fooling gunzip into emitting an incorrect error message. Transfer the file again in binary mode.
The MSDOS gzip package contains a file README.DOS, please read it. In short:
copy gzip.exe gunzip.exe
Use the zlib data compression library instead.
tarfiles compressed with gzip. On Unix extract them with:
gunzip < file.tar.gz | tar xvf - gunzip < file.tgz | tar xvf -If you have GNU tar you can use the
gtar xvzf file.tar.gz gtar xvzf file.tgz
tar.gzfile, gzip sometimes emits a
Broken pipeerror message. This can safely be ignored if
tarextracted all files without any other error message.
The reason for this error message is that
reading at the logical end of the
tar file (a block of
zeroes) which is not always the same as its physical end. gzip
then is no longer able to write the rest of the
into the pipe which has been closed.
This problem occurs only with some shells, mainly
bash. These shells report the SIGPIPE signal to the user,
but most others (such as
tcsh) silently ignore the pipe error.
You can easily reproduce the same error message with programs other than gzip and tar, for example:
cat /dev/zero | dd bs=1 count=1
tar.gzfiles are padded with zeroes to have a size which is a multiple of a certain block size. This occurs in particular when the compressed
tarfile is on a device such as a magnetic tape. When such files are extracted with a command such as
gunzip < file.tar.gz | tar xvf - gtar xvzf /dev/rmt/0gunzip decompresses correctly the
tar.gzfile, then attempts to decompress the rest of the input which consists of zeroes. Since those zeroes are not in gzip format, gzip ignores them. The
tarextract command still works correctly, since gzip has sent through the pipe all the data that
You can avoid this harmless warning by using the
option of gzip, as in:
gunzip -q < file.tar.gz | tar xvf - GZIP=-q gtar xvzf /dev/rmt/0 # for bash, ksh, sh ... (setenv GZIP -q; gtar xvzf /dev/rmt/0) # for csh, tcsh, ...
for GNU tar: tar tvfz file.tar.gz for any tar: gunzip < file.tar.gz | tar tvf -If you transfer the tar.gz file to another machine, test the destination file (after the file transfer), not the source file. This will detect bad file transfers. If you are not using tar, do at least
gzip -tv file.gzto test important files. Once the damage is made, it is somewhere between extremely difficult and impossible to recover damaged .gz files. If your data is so valuable that you are willing to spend a lot of time to recover part of it, read this.
Files already compressed without the patch are correct; the patch is useful only for decompression. Decompression with zcat outputs the correct data plus an error message length error that you can ignore for a single file. For example you can decompress with
gunzip < file.gz > filezcat on multiple files will stop at the first error so use the patch to avoid any problem.
To get a corrected binary, save the file 4g-patch.tar in the directory containing the gzip sources, then do:
tar xvf 4g-patch.tar make
For some systems (Solaris 2.6, AIX), you may get the error message
"Value too large for defined data type". A complete source
tree fixing this problem is available
thanks to Paul Eggert. For AIX, compile add
"-D_POSIX_SOURCE -D_LARGE_FILES -D_LARGE_FILE_API" to the compilation flags.
I have probably spent more time studying data compression patents than
actually implementing data compression algorithms. I maintain a list
of several hundred patents on lossless data compression algorithms,
and I made sure that gzip isn't covered by any of them. In
--fast option of gzip is not as fast
it could, precisely to avoid a patented technique.
The first version of the compression algorithm used by gzip appeared in zip 0.9, publicly released on July 11th 1991. So any patent granted after July 11th 1992 cannot threaten gzip because of the prior art, and I have checked all patents granted before this date.
During my search, I found two interesting patents on a process which is mathematically impossible: compression of random data. This is somewhat equivalent to patents on perpetual motion machines. Check here for a short analysis of these two patents.
gzip handles correctly dates within or after year 2000. More information about GNU software and year 2000 can be found here.
If you are satisfied with weak encryption, you can use zip.
tarfile then compress it:
for GNU tar: gtar cvzf file.tar.gz filenames for any tar: tar cvf - filenames | gzip > file.tar.gzAlternatively, you can use zip, PowerArchiver 6.1, 7-zip or Winzip. The
zipformat allows random access to any file in the archive, but the
tar.gzformat usually gives a better compression ratio.
In any case, there is no way to use AOL Instant Messenger on WebTV. Emailing me about this will not help in any way, I am not related to either WebTV or AOL. The correct contact for WebTV is here. Once again, the web page which led you here contains an error, you must not follow the instructions meant for Unix users only. Thank you for your understanding.
The home page of gzip's author
The home page of gzip's co-author Mark Adler
The data compression library, also written by Jean-loup and Mark.
All this started with the project.
FAQ (Frequently Asked Questions) of the comp.compression newsgroup.
Many thanks to
for supporting the gzip.org domain
and for its excellent service.
Thanks to Greg Roelofs for the gzip logo.
The gzip home page is http://www.gzip.org
Last modification: July 27th, 2003. Send your comments to email@example.com . Jean-loup's PGP key is here.
Back to the index
Back to Jean-loup's home page