this does not look like a tar archive ?
- State: Utah
- Country: United States
- Listed: 16 January 2024 16h46
- Expires: This ad has expired
Description
this does not look like a tar archive ?
“This does not look like a tar archive” : Understanding and Solving the Mystery
Have you ever tried to untar a .tar.gz file only to be greeted with the dreaded message “This does not look like a tar archive”? You’re not the first — the same error pops up on Super User, Stack Overflow, the Ubuntu Forums, and countless personal blogs. In this post we’ll unpack (pun intended) what triggers this error and walk you through practical, step‑by‑step solutions to get your archive back on track.
Why does the error appear?
The message is produced by tar when it cannot recognise the data as a valid tar archive. The most common culprits are:
- Wrong compression level – the file may be compressed twice or not at all.
- Corrupted transfer – FTP or other copy methods that used text (ASCII) mode instead of binary mode will corrupt the binary data.
- Wrong tool for the format – using
tardirectly on a gzip, bzip2, xz, or other stream that it doesn’t recognise. - File‑type mismatch – the file has a “.tar.gz” extension but isn’t actually a gzip‑compressed tarball (e.g., it’s a plain
.taror a completely different format).
How to diagnose the problem
- Check the magic bytes with
file:
“`bash
$ file suspicious.tar.gz
# Output might be:
# gzip compressed data, …
# tar archive
“`
If file says “ASCII text” or “HTML document”, the file is probably corrupted or not a tar at all.
- Inspect the first few bytes using
hexdumporxxdto confirm the magic header (e.g.,1F 8Bfor gzip).
“`bash
$ xxd -l 4 suspicious.tar.gz
00000000: 1f8b 0800 … # good gzip header
“`
- Verify the checksum (if you have an
.md5or.sha256file from the source). A mismatch points to a transfer error.
Step‑by‑step fix guide
1. Un‑gzip before untarring (the “classic” fix)
If you accidentally used tar -xzvf on a plain .tar, the command will fail. First split the two steps:
“`bash
# 1️⃣ decompress the .gz layer
gunzip file.tar.gz # produces file.tar
# 2️⃣ extract the tar
tar -xvf file.tar
“`
Alternatively, use the combined flag with the right option:
“`bash
tar -xvzf file.tar.gz # works if file is truly gzip‑compressed
“`
2. Ensure you use the right compression flag
- gzip →
-z(or--gzip) - bzip2 →
-j(or--bzip2) - xz →
-J(or--xz)
Example for a .tar.bz2 archive:
“`bash
tar -xvjf archive.tar.bz2
“`
3. Check the transfer method – binary is king
When downloading via FTP, always switch to **binary mode**:
“`bash
ftp> binary
ftp> get file.tar.gz
“`
If you already have a corrupted copy, re‑download the file using a more reliable protocol (HTTPS, SCP, rsync) or enable binary mode in your FTP client.
4. Assemble split archives correctly
If you have a multi‑part archive (e.g., file.tar.gz.001, file.tar.gz.002 …), you must concatenate them **in order** before untarring:
“`bash
cat file.tar.gz.* > combined.tar.gz
# now unzip & extract
gunzip -c combined.tar.gz | tar xvf –
“`
5. Re‑compress correctly if you need to
If you accidentally created a double‑compressed file (e.g., `gzip` then `tar`), reverse the process:
“`bash
# decompress the outermost layer first
gunzip file.tar.gz.gz # -> file.tar.gz
# then extract the inner tar
tar -xvf file.tar.gz
“`
Real‑world case studies
| Platform | Problem | Solution |
|---|---|---|
| Super User | Attempted tar -xvf file.tar on a .tar.gz and got “This does not look like a tar archive”. |
Un‑gzipped first, then extracted. Also added -z flag to command. |
| Stack Overflow | Downloading a large tarball via FTP in text mode corrupted the file. | Re‑downloaded using binary mode; checksum matched. |
| Ubuntu Forums | MySQL “tarball” appeared corrupted after a `scp` interrupt. | Re‑run `scp` with `-C` (compression) and verify with `md5sum`. |
Quick cheat‑sheet
| Command | Purpose |
|---|---|
file foo.tar.gz |
Identify file type |
gunzip foo.tar.gz |
Remove gzip layer |
tar -xvf foo.tar |
Extract a plain tar |
tar -xvzf foo.tar.gz |
Extract gzip‑compressed tar (one‑step) |
cat file.tar.gz.* > combined.tar.gz |
Concatenate multi‑part archives |
Conclusion – No more “not a tar archive” mystery!
“This does not look like a tar archive” is a classic symptom of a mismatch between the file’s real format and the way you’re trying to read it. By verifying the file type, using the right tar flags, ensuring binary transfers, and handling multi‑part archives correctly, you can fix the error in minutes.
Further reading & resources
- Video: Extracting a tar.gz file returns “This does not look like a tar archive”
- Article: Fixing “stdin: not in gzip format” error on Linux
- Man page for
tar - Wikipedia: tar (computing)
Got an unusual archive or still stuck on a particular error? Leave a comment below – I’ll be happy to help you untangle the issue! 🚀
9 total views, 0 today