How to Fix Linux tar: Unrecognized Archive Format Error
In this tutorial, you'll learn about How to Fix Linux tar: Unrecognized Archive Format Error. We cover key concepts, practical examples, and best practices.
You try to extract a tar file and get Unrecognized archive format — the file is corrupted, uses a compression format tar does not understand, or is not a tar archive at all.
The Problem
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
Or:
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
Step-by-Step Fix
Step 1: Check the actual file type
file archive.tar.gz
Expected for a valid gzip compressed tar:
archive.tar.gz: gzip compressed data, from Unix
If it shows HTML document or ASCII text, the file is not an archive.
Step 2: Use the correct extraction flags
# WRONG — no decompression flag
tar xf archive.tar.gz
# RIGHT — auto-detect compression
tar xf archive.tar.gz # tar >= 1.27 auto-detects
# For older tar versions
tar xzf archive.tar.gz # gzip
tar xjf archive.tar.bz2 # bzip2
tar xJf archive.tar.xz # xz
Step 3: Install missing decompression tools
# For .tar.gz
sudo apt install gzip
# For .tar.bz2
sudo apt install bzip2
# For .tar.xz
sudo apt install xz-utils
# For .tar.zst
sudo apt install zstd
Step 4: Fix corrupted downloads
If the file is corrupted, re-download:
# Verify checksum
sha256sum archive.tar.gz
# Compare with expected checksum
# Re-download
curl -OL https://example.com/archive.tar.gz
Step 5: Handle multi-part archives
# Split archives need to be combined first
cat archive.tar.gz.part* > archive.tar.gz
tar xf archive.tar.gz
Step 6: Extract without compression detection
If auto-detection fails, specify the format explicitly:
tar --use-compress-program=gzip -xf archive.tar.gz
Step 7: List contents without extracting
tar tf archive.tar.gz
If listing fails, the file is likely corrupted or not a tar.
Prevention Tips
- Always verify checksums after downloading
- Use the correct file extension naming (.tar.gz, .tar.bz2)
- Prefer
.tar.gzfor maximum compatibility - Use
filecommand to verify archive type before extraction - Keep compression utilities installed
Common Mistakes with tar error
- Using
returnto exit a function early instead of wrapping a pure value in the monad - Mixing let bindings with <- bindings in do notation, producing type errors
- Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
These mistakes appear frequently in real-world LINUX code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro