Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Zipping folders and their contents into a .zip file in Linux

I need to zip a file on Unix machine. File is about 200MB. What is the best compression tool? and provide me the command to zip the file.

File structure:

- /home/testuser/myfolder/
                     |__  Myfile1.dat [200MB]
                     |__  MyFile2.dat [500MB]
share|improve this question

migrated from Dec 8 '10 at 11:01

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Arjan, akira, BinaryMisfit Dec 9 '10 at 8:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Be aware that binary data files won't generally compress that well – Gareth Dec 8 '10 at 11:02
Why so? Can not I achieve it anyway? – Mohamed Saligh Dec 8 '10 at 11:03
Binary files may or may not compress well depending on how much repetition they contain, but they typically contain less repetition than a text file of similar size. The exception are already-compressed file formats, such as most media formats (.jpg, .mp3, .mpg, etc.), which, well, are already compressed. You should never see more than 1-2% reduction in file size for these formats and will often see them get bigger when zipped (but, again, by no more than 1-2%). – Dave Sherohman Dec 8 '10 at 11:15
well, /dev/zero contains a lot of repition :) – akira Dec 8 '10 at 12:50
I'd suggest defining 'best'. Best compression? Best compatibility with 3rd party tools? Best compatibility with other OSes? – Rich Homolka Dec 8 '10 at 15:40

One program to zip files would be:

$ zip

To zip a directory:

$ zip -r yourdirectory

Other popular ones are tar in conjuction with, e.g. Lempel-Ziv (gzip) or Burrows–Wheeler (bzip) style compression.

share|improve this answer

Basically the "best" compression is lzma. The order of available compressions is lzma, bzip2, gzip and finally compress. Whe you are saying Unix; what do you mean? If you happen to have GNU tar and friends you best option is lzma.


tar --lzma -cvf stuff.tar.lzma file1.dat file2.dat


tar -cvjf stuff.tar.bzip2 file1.dat file2.dat


tar -cvzf stuff.tar.gz file1.dat file2.dat

Of course if you don't have GNU tools:


tar -cvf stuff.tar file1.dat file2.dat
compress stuff.tar
share|improve this answer
OP asked for 'zip' – akira Dec 8 '10 at 12:51
Ok this might sound weird, but many people say zip and mean "to compress a file", thanks to WinZip. Same as when I say compress a file, I don't mean unix compress. As he was referring to the best way, I though he knew about the zip / unzip commands... – Sean Farrell Mar 20 '12 at 9:10

As already mentioned, binary files do not compress well compared to plain text. I'd just gzip or bzip the file and be done with it. The time spent compressing it to the max with LZMA for example may eventually outweight the time for the extra few MB's of transfer, depending on your transfer medium.


tar czvf myfolder.tar.gz /home/testuser/myfolder
share|improve this answer

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