How to solve: stdin: not in gzip format

The file extensions could be deceptive. Learn what to do with the 'not in gzip format' error with tar command in Linux.
Warp Terminal

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)
πŸ’‘
The file extensions in Linux has no real meaning. You can name a csv file, a zip file. You can choose to not use any extension at all.

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
πŸ“‹
Now, that’s how I fixed this problem. I advise you to run the file command on your file and see what kind of archive file it is.

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 :)

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries πŸ•΅οΈβ€β™‚οΈ

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

It's FOSS

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.