Skip to content

How to Fix Linux tar: Unrecognized Archive Format Error

DodaTech Updated 2026-06-24 3 min read

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.gz for maximum compatibility
  • Use file command to verify archive type before extraction
  • Keep compression utilities installed

Common Mistakes with tar error

  1. Using return to exit a function early instead of wrapping a pure value in the monad
  2. Mixing let bindings with <- bindings in do notation, producing type errors
  3. 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

### How do I fix tar: Exiting with failure status due to previous errors?

This means tar encountered a fatal error. Look at the line immediately above this message. Common causes: unsupported compression, corrupted archive, or disk full. Fix the underlying issue and try again.

What is the difference between .tar.gz, .tar.bz2, and .tar.xz?

All are tar archives with different compression algorithms: gzip (fast, moderate compression), bzip2 (slower, better compression), xz (slowest, best compression). Use gzip for frequent transfers and xz for long-term storage.

Why does tar say "Cannot open: No such file or directory"?

The archive file does not exist, the path is wrong, or the file name has typos. Use tab completion to verify the filename. If the file is in a different directory, use the full or relative path.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro