The other day, I tried to unzip a file MyFile.tar.gz which looked like a gzipped file by the name. But while unzipping I encountered an error βgzip stdin not in gzip formatβ which was as following:
$tar xvzf MyFile.tar.gz
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error exit delayed from previous errors
The error indicates that the file is not in gZipped format. And I asked the tar command to extract a file which is in zip format (z
in tar xvzf
is for zip). Since the file is not in gzip, tar command complains about it.
Even though the file name ends with the extension .gz
, the file is not in gzip format. Then which format is it in? To find out, I ran the file command on it:
file MyFile.tar.gz
And that file command gives me the actual file type:
MyFile.tar.gz: POSIX tar archive (GNU)
Reason
The reason for the error is quite evident. The file is not a gzipped file but a POSIX tar archive file.
This means it was not zipped at all but instead, it was compressed using tar. It was simply renamed afterward, I believe.
Perhaps the creator of the file wanted to gzip a directory but couldnβt do that because the directory needs to be archived using tar first. Confused? I recommend reading this article to learn the difference between tar and zip.
Solution
Since it was not a gzipped file, a simple tar is able to extract the file:
tar xvf MyFile.tar.gz
If your file is in POSIX tar archive format, you can use the same command that I have used in the above example.
If itβs in some other archive format, then you should run the appropriate command to extract the archive file.
You have to search on the internet a bit about how to extract that certain kind of archive file. It should not be a difficult task if you have even a little bit of experience with Linux commands.
I hope you found it helpful. Cheers :)