This write-up guides how to solve “gzip:stdin: not in gzip format” in Linux and we will also explain the root cause of this error.
How to fix gzip: stdin: not in gzip format in Linux
We have a file in our system with the name “myfile.tar.gz”, we will try to extract the file using the command:
The error will be generated, which means the file is not in the gzip format. To know the format of file, we will use the file command:
The file, myfile.tar.gz is in the POSIX tar archive (GNU) format instead of the gzip format. It means that the file has only been archived and not compressed using gzip. The name of a file has been changed by adding the “.gz” extension. Now as we know this file is only archived and not compressed, we can extract the file removing the “z” flag as this flag is used for gzipped files only.
We have another file with the name of “myzipfile.tar.gz” which is compressed using gzip utility. We will try to extract the file using the command:
The file has generated no error because the file is compressed using the gzip utility instead of adding the extension.
Conclusion
The error “gzip: stdin: not in gzip format” occurs when the file is not in the gzip format. There are two cases; either the file is only archived and renamed with the “.gz” extension or the file is in some other format. The gzip is used to zip, compress, or decompress the files. In this write-up, we have discussed the “gzip: stdin: not in gzip format” error and explained with examples why this error occurs and how it can be solved.