I was attempting to untar a .tar.gz file, but came across this error:

gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now

The tar.gz file includes a .tar file, which when untarred results in:

tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now

I tried both –ignore-zeros and –ignore-failed-read, although they both didn't work.

Is there any way I could extract this file even if it is corrupted?

The file type in question: .tar.gz: Gzip Compressed Data, from a UNIX system.

7 Answers 7


Check two items:

(1) Is the FILE INCOMPLETE due to a faulty download? Re-download, and use the -c option if your are using wget. (happens all the time).

(2) Does the .tar or .tar.gz filename have ILLEGAL CHARACTERS. It's best to keep archive names simple, short, composed of letters and numbers. (happens all the time). So just rename the file. This one nailed me recently as I thought it would be convenient to include a time/date stamp as part of the archive name. BAD IDEA!

  • As for me, the problem lied within the first case. After comparing the checksums of both files before the data transfer, they turned out be different.
    – xquilt
    Aug 18, 2022 at 18:25

You don't. It appears the file has been truncated. How long is it? If you only have the first few bytes then you're done.


are you unpacking the .tar.gz file on the same platform it was made on? there are some differences between older Unix versions of tar, such as the non-GNU versions of tar that have shipped with Solaris, and the GNU tar that ships with Linux, etc. If you're going to unpack an archive with GNU tar, it's best to create it with GNU tar.

how does your system look for disk space? was the disk full when you made the archive, or is it full as you attempt to unpack it?

did you create the archive with a cron job? without output redirection, cron can do funky things to archives due to limitations in the size of output it will allow to STDOUT. If you're making an archive in cron, and you're using -v with tar, try redirecting STDOUT to a file, and STDERR, too. See if that helps. tar -cvf archive.tar.gz /path/ 1>archive.stdout.log 2>archive.stderr.log or something like that.

  • i am trying to extract cpanel backup site made by .tar.gz , the problem is this site large over 13 G.B and i think it didn't backup the file as well , so it's corrupted , all i want is how could i skip the corrupted files and extract the files has been packed as well ?
    – iLinux85
    Nov 5, 2012 at 15:18
  • @iLinux85, the file is probably truncated (cut short, the "unexpected EOF"), you can only recover what is stored in it.
    – vonbrand
    Feb 25, 2020 at 12:31

I had the same error.

My problem was trying to use tar to unzip before the upload was complete.


just faced this recently, solution was to rename the file (remove the _).E.g Bad file name which was causing issue MAA07-0100-0100-01AAA_show_tech_output.tgz , renaming this to MAA07-0100-0100-01AAA.tgz helped to resolve the issue.


My issue was that I was storing the tar files in git, and apparently git does not do well with large binaries. It would work fine for a while but would eventually corrupt them.


My solution to the problem was to rename the tar archive twice. I know it does sound ridiculous, but it worked for me and saved a lot of time on rearchiving.

I had a big, 9 GB, tar gzip archive named 'STRING152_20200221.tar.gz' which produced the errors reported by the OP. As advised above, I renamed it to just 'STRING.tar.gz'. The errors persisted. Then I renamed it back to the original name 'STRING152_20200221.tar.gz' and it unarchived successfully.

No manipulations with the archive except its name were done.

My tar version is 'tar (GNU tar) 1.26'. I am also on CentOs (CentOS Linux release 7.4.1708 (Core))

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .