How to fix unzip error "End-of-central-directory signature not found"

Last updated on February 20, 2021 by Dan Nanni

Question: I downloaded a zip file from somewhere. When I try to extract compressed files from the zip file using the unzip command, I am not able to unzip it and instead getting the following error.
End-of-central-directory signature not found.  Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive.  In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
How can I fix this unzip error?

If you are unable to extract files from a zip file and instead getting the error "End-of-central-directory signature not found", here is what you can do.

Foremost, you want to check that the archive is indeed a zip file, not generated by other similar archive programs such as gzip. So try uncompressing it with gunzip to eliminate this possibility.

If this does not help, changes are that the zip file was incompletely downloaded or got corrupted on your disk somehow. In the rest of the tutorial, let's find out how to fix, or at least get round, the unzip error when a zip file is corrupted or end of the file is truncated.

How Files are Stored in a Zip Archive

For those of you who want to understand the problem better, here is a brief overview of how files are stored in a zip archive.

By design a zip archive file can store (and optionally compress) multiple files in it. The zip archive contains a special directory called "central directory" at the end, which identifies what files are in the zip file. The main reason for including the central directory at the end of an archive is so that the archive can be updated easily. For example, when a (large) zip file is updated by adding a new file and deleting one existing file, these updates can easily be applied with the central directory information without scanning the entire zip file.

Each file in a zip archive is also associated with its "local file header" which contains necessary metadata about the file, such as file size, file name, etc.

The unzip command verifies the integrity of a zip file by looking for the "end of central directory record" with a specific signature, and refuse to extract files without the signature.

Method One: jar

One option to extract a corrupted zip file is to use the jar command which comes with Java development kit (JDK). Originally the jar command creates and extracts an archive for Java-specific class files and metadata, but JAR archives are in fact stored in the ZIP format. Thus you can extract a regular zip file with jar. The difference is that jar extracts files without checking the central directory signature in a zip archive.

To extract a zip file with jar, use the xvf option:

$ jar xfv

You will still see an error "Unexpected end of ZLIB input stream" due to the missing central directory record. But jar will scan the archive and extract individual files one by one based on their local file headers.

It's possible that you may not extract every file stored in the original zip archive if the archive is incomplete. Another caveat is that if the original archive went through various updates before (e.g., removing/updating files in the archive), extracting files solely based on their file headers without the central directory may result in outdated files being extracted.

Method Two: fastjar

On Debian-based Linux, you don't have to install the bulky JDK just to use the jar command. Instead, you can use fastjar, which is a lightweight C implementation of the original Java-based jar command. The entire fastjar package is less than 200KB.

Similar to jar, the fastjar command does not check for the central directory signature before extraction.

To install fastjar in Ubuntu, Debian, Linux Mint:

$ sudo apt install fastjar

To uncompress files from a zip file with fastjar:

$ fastjar xfv

You may also see an error "CRCs do not match" during extraction.

Method Three: zip

The zip command (counterpart for unzip) provide an option -FF (or --fixfix) to "fix" a zip archive which is truncated and thus missing the central directory signature. With this option, the zip command scans the zip file from the beginning and tries to reconstruct the central directory.

To fix the archive, run the zip command in the following format. The --out option is used to specify the name of a fixed archive.

$ zip -FF --out

Then try and uncompress the fixed archive:

$ unzip

Method Four: 7zip

Another option to deal with a truncated zip file is to use 7zip command, which is another archive program for zip files.

Similar to jar or fastjar, the 7z command does not check for the end of central directory signature before extraction.

$ 7z x

The command may throw Unexpected end of archive warning during extraction.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal (Credit Card) or Bitcoin (1M161JGAkz3oaHNvTiPFjNYkeABox8rb4g).

Please note that this article is published by under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean