
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 :)
It's FOSS turns 13! 13 years of helping people use Linux โค๏ธ
And we need your help to go on for 13 more years. Support us with a Plus membership and enjoy an ad-free reading experience and get a Linux eBook for free.
To celebrate 13 years of It's FOSS, we have a lifetime membership option with reduced pricing of just $76. This is valid until 25th June only.
If you ever wanted to appreciate our work with Plus membership but didn't like the recurring subscription, this is your chance ๐