The error gzip: stdin: not in gzip format appears when tar hands the file to gzip for decompression and gzip finds data that is not a gzip stream. The usual cause is simple: the file was never compressed, it is a plain tar archive that someone renamed to .tar.gz.
Here is the command that triggers it. You try to extract archive.tar.gz with the -z flag, which tells tar the file is gzipped:
tar -xvzf archive.tar.gz
Instead of extracting, you get this exact output:

I reproduced this on a current Linux system by creating a plain tar archive of one text file, copying it to archive.tar.gz, and running the command above. The full failure reads:
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
What Causes This Error?
Tar does not decompress anything itself. The -z flag makes it pipe the archive through gzip, and gzip refuses input that lacks the gzip magic bytes. So the message means exactly what it says: the stream arriving at gzip is not in gzip format.
Check what the file actually is before touching it. The file command reads magic bytes, not the filename:
file archive.tar.gz

In my run, the output was “archive.tar.gz: POSIX tar archive (GNU)”. The file is an uncompressed tar archive wearing a .gz extension. That happens when a script or download renames the file, or when someone archives with tar but never applies gzip.
You can confirm without tar at all. Running gzip -t on the same file reports “not in gzip format”, which isolates the problem to the file rather than your tar flags:
gzip -t archive.tar.gz
# gzip: archive.tar.gz: not in gzip format
Difference Between Tar, Zip, and Gz
Tar bundles many files into one archive but compresses nothing. Gzip compresses a single stream but cannot bundle files.
A .tar.gz is both steps combined, tar first and gzip second. Zip does archiving and compression in one tool, which is why .zip files need no helper flag.
This split explains the error. A genuine .tar.gz starts with the gzip magic bytes 1f 8b, which is why tar -z works on it. A renamed plain .tar starts with tar’s own header instead, so gzip rejects it immediately.
Solution for the gzip: stdin: not in gzip format Error
If file reports a POSIX tar archive, extract it without -z and tar will read it directly:
tar -xf archive.tar.gz
The extension does not matter here because tar detects the format from the bytes. Running exactly this on a renamed plain tar extracted note.txt cleanly with no error:

For comparison, a genuine gzip-compressed archive identifies itself differently and extracts fine with -z:
file good.tar.gz
# good.tar.gz: gzip compressed data, from Unix, original size modulo 2^32 10240
tar -xvzf good.tar.gz
# note.txt
If the file turns out to be some other format entirely, use the matching extractor. For RAR archives, see how to install WinRAR on Linux. For standard zip files, unzip handles them directly.
Common Mistakes to Avoid
- Trusting the extension: Extensions are decoration on Linux. Always settle the question with file before choosing flags.
- Using -z reflexively: Adding -z to every tar command causes this error on uncompressed archives. Plain tar -xf works on compressed and uncompressed tars alike because tar auto-detects the compression.
- Retrying a corrupted download: If file says “gzip compressed data” but extraction still fails midway, the download is likely truncated. Compare checksums or fetch it again rather than fighting the flags.
Conclusion
The error boils down to a mismatch between the file’s actual bytes and the -z flag. Run file on the archive, drop the -z when it is a plain tar, and keep -z only for genuinely gzip-compressed data. When in doubt, tar -xf alone extracts any tar variant correctly.
How do I fix the “stdin: not in gzip format” error in Ubuntu?
Run file on the archive to identify its true format. If it reports a POSIX tar archive, extract it with tar -xf filename.tar.gz without the -z flag.
What does the error “gzip: stdin: not in gzip format” mean?
It means tar passed the file to gzip for decompression, but the data does not start with gzip’s magic bytes. The file is usually an uncompressed tar archive that was renamed to .tar.gz.
How can I determine the file type of an archive in Linux?
Use the file command followed by the filename, for example file myfile.tar.gz. It reads the file’s magic bytes rather than trusting the extension.
Why do I also see “tar: Child returned status 1” after the gzip error?
Tar spawned gzip as a child process to decompress the archive. When gzip exits with status 1, tar reports the child’s failure and stops with its own unrecoverable error.
How do I extract a gzip-compressed tar file?
Use tar -xvf myfile.tar.gz with the -z flag, or simply tar -xf myfile.tar.gz since modern GNU tar auto-detects gzip compression.
What is the difference between a gzipped file and a tar file?
A tar file bundles multiple files into one uncompressed archive. Gzip compresses a single data stream. A .tar.gz file is a tar archive that was then compressed with gzip.
