not in gzip format

How to Fix Stdin: Not in GZIP Format

Gzip file format allows you to compress one or more files & folders into a single file. However, while extracting/uncompressing this file, sometimes, you may get the error ‘stdin: not in gzip format’. Here is how to fix this problem.


How to Fix Stdin: Not in GZIP Format

Let us say you run the tar command on the gzip file sample.tar.gz

$ tar -xvzf sample.tar.gz
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error exit delayed from previous errors

As you can see, the error message says that the file is not in gzip format. Please note, only a file that has been compressed to .gz file format will work properly in this case.

If you have renamed a .tar file as .tar.gz file, or .tar.bz2 to .tar.gz file, or .zip file to .gzip file, you will get this error.

Alternatively, you may get this error if you have used -z option on a .tar file. For example, if you have a .tar file and not a .tar.gz file, don’t use -z option. Just use -xvf

$ tar -xvf sample.tar

This is because they all have different algorithms for archival/compression.

So use the file command to identify the original file format of your .gz file.

$ file sample.tar.gz
sample.tar.gz: POSIX tar archive (GNU)

As you can see, the sample.tar.gz file is just a POSIX archive file. So you need to use only -xvf option, with tar command.

$ tar -xvf sample.tar.gz

If your file is in some other format, then you need to use the appropriate tool to extract it. For example, if it is a zip file then use unzip command.

$ unzip sample.tar.gz

Please note, you will need to install unzip command separately on your system with the following command. It is not present on most Linux systems.

$ sudo apt install unzip     [On Debian/Ubuntu] 
$ sudo yum install unzip    [On CentOS/RHEL]
$ sudo dnf install unzip     [On Fedora 22+]

If it is bz2 file, use bzip2 command to decompress it.

$ sudo bzip2 -d sample.tar.gz

Again, you will need to install bzip2 with the following command, since it is not present on most Linux systems.

$ sudo apt install bzip2     [On Debian/Ubuntu] 
$ sudo yum install  bzip2    [On CentOS/RHEL]
$ sudo dnf install bzip2     [On Fedora 22+]

In this short article, we have learnt how to fix ‘stdin: not in gzip format’ error in Linux. You can use these steps on any Linux system.

Also read:

How to Find & Kill Zombie Process in Linux
How to Disable Strict Host Key Checking in SSH
How to Create Superuser in Django
How to Print in Same Line in Python
How to Import from Another Folder in Python

2 thoughts on “How to Fix Stdin: Not in GZIP Format

  1. I was sent a series of .gz files. Originally, they all decompressed fine using 7Zip or gzip. Being large, I removed the decompressed versions. I now need them again, but while some decompress fine, others now say ‘not in gzip format’. If I try it tells me ‘data’. generates strings of ‘random’ characters, so the files are still compressed / in another format. I can’t believe the files are not recoverable but I have no idea how. Any suggestions gratefully received. Thanks.

    • I would suggest you use file command to determine the correct type of compression for your compressed files. Here is its syntax
      $ file filename

      The above command’s output will give you the proper compression used to create the file in first place. Then you use the correct utility to decompress. For example, it may be that your compressed files are actually POSIX tar files that just need unarchiving using tar command, and not gzip/7z.

Leave a Reply

Your email address will not be published.