122

I want to extract an archive named filename.tar.gz.

Using tar -xzvf filename.tar.gz doesn't extract the file. it is gives this error:

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error exit delayed from previous errors
shgnInc
  • 1,591
  • 1
  • 17
  • 31
Kabir
  • 2,026
  • 4
  • 18
  • 24

8 Answers8

185

If file filename.tar.gz gives this message: POSIX tar archive, the archive is a tar, not a GZip archive.

Unpack a tar without the z, it is for gzipped (compressed), only:

mv filename.tar.gz filename.tar # optional
tar xvf filename.tar

Or try a generic Unpacker like unp (https://packages.qa.debian.org/u/unp.html), a script for unpacking a wide variety of archive formats.

determine the file type:

$ file ~/Downloads/filename.tbz2
/User/Name/Downloads/filename.tbz2: bzip2 compressed data, block size = 400k
pce
  • 4,160
  • 1
  • 16
  • 24
  • 7
    Thanks @pce for your support. your answer is correct. `tar xvf filename.tar.gz`. It works for me. – Kabir Apr 01 '13 at 13:18
  • tar xvf hadoop-2.7.2.tar tar: Ceci ne ressemble pas à une archive de type « tar » tar: Arrêt avec code d'échec à cause des erreurs précédentes – EL missaoui habib Feb 23 '18 at 16:04
16

As far as I can tell, the command is correct, ASSUMING your input file is a valid gzipped tar file. Your output says that it isn't. If you downloaded the file from the internet, you probably didn't get the entire file, try again.

Without more knowledge of the source of your file, nobody here is going to be able to give you a concrete solution, just educated guesses.

thelr
  • 858
  • 7
  • 26
  • 6
    This made me take a second look at the file I was downloading. It was from apache and the url ends in .tar.gz so I just copy and pasted it. However, that link wasn't for the tarball, it was for a page listing mirrors for the tarball. So for 30 minutes I was trying to untar an html page. Wtf apache. – eddiemoya Nov 30 '15 at 20:52
  • 1
    I had this issue, double check that your file is the correct size, also use a checksum if possible. – kiwicomb123 Apr 19 '17 at 01:26
7

I have the same error the result of command :

file hadoop-2.7.2.tar.gz

is hadoop-2.7.2.tar.gz: HTML document, ASCII text

the reason that the file is not gzip format due to problem in download or other.

EL missaoui habib
  • 1,009
  • 1
  • 14
  • 24
  • did you manage to sort this out? Having same issue here. – arilwan Jul 13 '20 at 13:44
  • @arilwan If you're having an issue with this, try opening the file in a text editor. The answer is saying that there was a download error, so they got an HTML error page INSTEAD of the expected gzip file. The download program (wget?) still saved it with the .gz extension. – thelr Apr 19 '21 at 12:50
5

It happens sometimes for the files downloaded with "wget" command. Just 10 minutes ago, I was trying to install something to server from the command screen and the same thing happened. As a solution, I just downloaded the .tar.gz file to my machine from the web then uploaded it to the server via FTP. After that, the "tar" command worked as it was expected.

Volkan
  • 51
  • 1
  • 1
2

Internally tar xcvf <filename> will call the binary gzip from the PATH environment variable to decompress the files in the tar archive. Sometimes third party tools use a custom gzip binary which is not compatible with the tar binary. It is a good idea to check the gzip binary in your PATH with which gzip and make sure that a correct gzip binary is called.

0

A tar.gz is a tar file inside a gzip file, so 1st you must unzip the gzip file with gunzip -d filename.tar.gz , and then use tar to untar it. However, since gunzip says it isn't in gzip format, you can see what format it is in with file filename.tar.gz, and use the appropriate program to open it.

built1n
  • 1,428
  • 14
  • 24
0

Check to make sure that the file is complete. This error message can occur if you only partially downloaded a file or if it has major issues. Check the MD5sum.

mcragun
  • 129
  • 1
  • 4
0

The other scenario you mush verify is that the file you're trying to unpack is not empty and is valid.

In my case I wasn't downloading the file correctly, after double check and I made sure I had the right file I could unpack it without any issues.

David Castro
  • 1,197
  • 13
  • 14