Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

To illustrate the point: I have downloaded the LEDA library from the company's website. Using tar -xzf on it fails:

$ tar -xzf LEDA-6.3-free-fedora-core-8-64-g++-4.1.2-mt.tar.gz 
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors

However, gunzip followed by tar -xf works just fine:

$ gunzip LEDA-6.3-free-fedora-core-8-64-g++-4.1.2-mt.tar.gz
$ tar -xf LEDA-6.3-free-fedora-core-8-64-g++-4.1.2-mt.tar
# no error

Can anyone tell me why this could be?- I'd want the standard tar command to work all the time.

share|improve this question
What operating system? IIRC there are Unixes with a tar that does not implement -z – Bananguin Apr 15 '13 at 19:05
@user1129682 From the company's site, it looks like it only has options for Linux and Win... – MattDMo Apr 15 '13 at 19:07
If your tar does not support z, use a pipe instead: gunzip < archive.tar.gz | tar -x should work everywhere. – frostschutz Apr 15 '13 at 19:07
If your copy of tar does not support gunzip decompression, you can do the following instead: gunzip -c $file | tar -x. It's common to wrap that up in a shell function. – Evan Teitelman Apr 15 '13 at 19:08
I just downloaded that archive, and indeed tar xzf gives an error, on Debian GNU/Linux (which of course uses gnutar). Odd. – derobert Apr 15 '13 at 19:29
up vote 9 down vote accepted

What appears to have happened is that they've double compressed the archive.

If you run file on your gunzip'd file, you'll find its still a gzip archive. And if you rename it to have .gz again, you can gunzip it again.

It seems recently gnu tar will automatically add the -z option, provided the input is a file. So, that's why it works without the -z option after you'd already run gunzip once, tar automatically added it.

This behavior is documented, from the info page:

"Reading compressed archive is even simpler: you don't need to specify any additional options as GNU `tar' recognizes its format automatically. [...] The format recognition algorithm is based on "signatures", a special byte sequences in the beginning of file, that are specific for certain compression formats."

That's from §8.1.1 "Creating and Reading Compressed Archives."

share|improve this answer
Very well spotted! Confirmed with all combinations of gunzip and tar. – user538603 Apr 15 '13 at 20:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.