I tried a majority of the formats (gzip, etc.) to extract a zip file with tar, and when I became frustrated enough to Google for it, I found no way to extract a zip file with tar and only recommendations to use zip or unzip. As a matter of fact, my Linux system doesn't even have a zip utility, but only unzip (leaving me to wonder why this is the main recommended option). Of course unzip worked, solving my problem, but why can't tar extract zip files? Perhaps I should instead be asking, what is the difference between zip and the compression methods supported by tar?

closed as primarily opinion-based by derobert, Braiam, slm Jul 23 '14 at 21:34

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Just a note, bsdtar can extract .zip archives :P – HalosGhost Jul 23 '14 at 20:41
  • 11
    You mean like in, "why can't I use a can-opener to chop carrots?" The thing is tar has it's own file-format, and then compresses that with whichever method you choose. zip is a whole different beast. Simple as that. It's "the unix way", have one small tool that does one job well, rather than having an egg-laying, wool-bearing milk-sow that will cater to all your needs. – tink Jul 23 '14 at 20:54
  • I slightly edited my question to make this clearer, but I think my question clearly implied that I thought zip was a compression format and not a replacement tool for tar+compression. The answer that I chose corrected what I was assuming and showed that the answer wasn't opinion-based. – Pluto Jul 23 '14 at 22:02

The UNIX philosophy is to have small tools. One tool is doing exactly one thing, but this especially well.

The tar tool is just combining several files into a single file without any compression.

The gzip tool is just compressing a single file.

If you want to have both, you just combine both tools resulting in a .tar.gz file.

The zip tool is a completely different thing. It takes a bunch of files and combines them into a single compressed file. With totally different algorithms.

If you want one tool to rule them all use atool. It will support a whole bunch of different formats simply by detecting the format and calling the correct tool.

  • Thank you for actually explaining the purpose of both instead of just explaining what tar does. I soon figured out the answer after looking at a wikipedia article that listed formats for "Archiving," "Compression," and both in three different tables. I figured I'd wait for an answer that explained this clearly. – Pluto Jul 23 '14 at 21:41
  • To be a bit picky, the gzip compression algorithm is the same one used by zip. The difference is that gzip is meant to compress any byte stream, including a .tar file, while zip, derived and inspired by PKZIP, compresses and archives in one step (and in that order). – Joe Sewell Jan 13 '15 at 18:53

Long story short: tar GNU tool doesn't pipe through zip/unzip since nobody cares.

Long story, original size:

tar wasn't initially meant for uncompressing and compressing files, but to archiving several files in a single big file. Since people not only wanted to archive their files, but also, compress them, so they just pipe the tar output through any compressor that accepts data stream input and drops the results to a file. Profit!

Now, to make such task a painless as possible, tar decided to pipe internally the files generated to compression tools, like gzip, lzma, etc., which were activated by special flags for each format when running tar. That's why when you try to extract a corrupted file through tar you are shown the underlying tool error, instead of tar's:

$ tar zxf damaged.tar.gz
gzip: damaged.tar.gz: unexpected end of file

So, it isn't that tar doesn't uncompress zip files, just that tar doesn't have the ability to pipe it through the correct tool, since nobody actually bothered to implement it, and zip already accomplish the file archive function of the tar file format there's less reason for tar to support it.

Now, there are all-in-one tools that compress/uncompress everything you throw at them, again, you need to have the correct tools to actually support it. If you don't have them, the tool will fail.

  • 1
    Well, beyond just no one implementing the right tool to pipe through, there isn't one: tar files only combine multiple files into one. Compression is separate. So the filters tar pipes through just compress/decompress a single tar file. Zip works differently; it uses one integrated tool to compress and combine (a similar Unix program is afio). – derobert Jul 23 '14 at 21:19
  • I'd suggest mentioning a few of the all-in one compression tools that exist. E.g., there is the GNOME file-roller... – derobert Jul 23 '14 at 21:20
  • @derobert file-roller only supports zip if you have unzip/zip/p7zip installed. Otherwise is just as useless like tar. – Braiam Jul 23 '14 at 21:23
  • tar only supports its various compressed versions if you have the relevant tool installed as well... The multi-format archive managers are useful because they give you a consistent interface to handle different archive formats. – derobert Jul 23 '14 at 21:25
  • @derobert exactly. – Braiam Jul 23 '14 at 21:25

A tar file is a file format in itself designed for tape archives. This format can then be compressed using (for example) gzip or bzip2 compression formats. When you extract a compressed tar file, you effectively uncompress it, then extract the original files from the uncompressed tar file.

When you extract a zip file there is no tar file within it, just all your original files. Therefore there is no reason for tar to be involved in the process at all.

You can also compress files using gzip or bzip2 by themselves just like you can create zip files (with no tar involved). When you uncompress these files, you use gunzip or bunzip2 and not tar.


As the answer "Some things just are and we should accept them" does not sit well with me either, I just did some digging (always good to learn something new isn't it?).

So it looks like the issue is one of where the tools went and what their aim was.

Instead of paraphrasing what I found and making the waters needlessly murky (obfuscation pisses me off), take a look at this article: http://www.differencebetween.net/technology/difference-between-zip-and-gzip/

I suppose that tar could have built in zip support, but the methodologies are apparently fundamentally different. Or perhaps they thought why would someone use this archiving tool to manage files from another archiving and compression tool (or perhaps there was some argument between the two original coders and there was a restraining order filed that disallowed the zips from crossing the application boundary... yes I am kidding).

Not the answer you're looking for? Browse other questions tagged or ask your own question.