On Linux/Unix, does .tar.gz versus .zip matter?
Cross-platform programs are sometimes distributed as .tar.gz for the Unix version and .zip for the Windows version. This makes sense when the contents of each must be different.
If, however, the contents are going to be the same, it would be simpler to just have one download. Windows prefers .zip because that's the format it can handle out of the box. Does it matter on Unix? That is, I tried today unzipping a file on Ubuntu Linux, and it worked fine; is there any problem with this on any current Unix-like operating system, or is it okay to just provide a .zip file across the board?
19 Answers
Yes, it matters.
Actually, it depends.
tar.gz
- Stores unix file attributes: uid, gid, permissions (most notably executable). The default may depend on your distribution, and can be toggled with options.
- Consolidates all files to be archived in one file ("Tape ARchive").
- Actual compression is done by GZIP, on the one .tar file
zip
- Stores MSDOS attributes. (Archive, Readonly, Hidden, System)
- Compresses each file individually, then consolidates the individually compressed files in one file
- Includes a file table at the end of the file
Because zip compresses the files individually, a zip-archive will most-likely have a larger size (especially with many smaller files - think config files).
So you see, appart from file size, if you zip a bunch of files on Linux/Unix, and then unzip them, the file-attributes will be gone (at the very least those not supported by MS-DOS - depends on what ZIP-software you use). This may matter, or it may not, in which case it doesn't matter (because the file-size difference is in most cases negligible).
2tar gz is better for Linux/Unix as it retains permissions, such as "executable" on scripts.
2Most popular Linux distros these days are by default equipped with zip compatibility. But as stated by nc3b, tar and gzip are more common on Linux/Unix systems. If you need 95% compatibility on these systems, consider using tar and gzip. If you need only 85%, zip will do fine.
tar/gzip is a pretty crappy format since the archive cannot be randomly accessed, updated, verified or even appended to... without having to decompress the entire archive.
zip is much better in that regard.... you can quickly obtain the contents of a zip file, append to it without recompressing the first part, etc.
zip has some size limitations ... depending on the version of "zip" that you use... and these can be a problem. but the standard info-zip tool that comes with most linux-like os'es has no size limitations and preserves file permissions just fine.
see: for capabilities
2Barebones Unix installs don't contain unzip (i.e. server installs), but they always contain tar and gzip. If your audience is servers, I'd go for gzip.
Also gzip has greater compression than zip, so the file will be smaller.
4Yes, it matters. Tar is an archiver. And in tar.gz, we compress that archive.
Zip is both an archiver and compressor.
If you compare compression, from my experience, gzip is much better than zip.
And the other significant difference is mentioned in another answer. If you have a very big file archive, and want to extract a small file, Zip allows you to do that. But with tar.gz, you need to extract entire archive.
1The decision basically comes down to these:
GZIP keeps Unix file permissions, as files being allowed to execute.
On the other hand ZIP works out of the box in Windows.
tar and gzip are a lot more common on *nix-es than unzip. For instance, at the moment on my arch-2009.08 there is no unzip.
I have experienced that there is concrete difference.
If you are compressing programs with libraries, zip format may lead to "file format not recognized" or "syntax error", because of the lack of information. Tar compression ensure to keep safe also all attribute.