21

what factors should be considered when choosing among 7zip, xz, gzip, tar, etc. for compressing and archiving files?

5
  • This is opinion-based and is likely to be closed. Edit it to be a objective and it might be a very interesting question. Commented Nov 12, 2016 at 3:49
  • I have seen gzip most of the time and compression level is good too. Commented Nov 12, 2016 at 4:18
  • If you want the best bang for your multi-cpu bucks, then you must consider pzstd. It is, however, not widespread. github.com/facebook/zstd/tree/dev/contrib/pzstd Commented Nov 12, 2016 at 7:15
  • I don't think title question is opinion based nor it should be closed as it's not been actually answered. Commented May 21, 2022 at 15:53
  • The title question might not be opinion based, but that one definitely lacks focus. Commented Aug 14 at 1:52

2 Answers 2

49

I first want to clarify that, of the list you provided, tar is the only one that is not a compression algorithm. tar is short for Tape Archive, and is used to create archive files. In short, a single file that consists of one or more files. It is used to bundle files together so that they can be compressed by a compressor that is only able to compress a single file.

In terms of availability, zip is widely available across UNIX (Linux/BSD/MacOS) and Windows systems. Therefore a zip file is highly portable. Tools to compress/decompress xz and gzip files are also available on Windows systems, but are more commonly seen and used on UNIX systems.

xz and 7zip are known to have a better compression algorithm than gzip, but use more memory and time to compress/decompress. This topic is nicely discussed here.

I would recommend using gzip when less memory is available, and compression/decompression speed is a concern. 7zip and xz can be used when space is a concern and compression/decompression speed is not.

Some nice benchmarks on these algorithms can be found here. Note: LZMA is the compression algorithm used by 7zip and xz.

5

Only answers the original question within the original context. The question:

What would you recommend me to use: 7zip, xz, gzip, tar, etc which is more or less available on the most linux distributives and what does compression the best?


Just use tar with gzip a la tar -czvf <filename.tar.gz> /path/to/files

Very often the difference in compression algorithms is either negligible (e.g. bzip2) or is dependent on what kind of data you are talking about. For general-purpose compression, the best advice I think is just to stick with what is standard.

Also it just makes life easier to use the same formats as everyone else unless there is a clear and significant advantage. So you'll want to get used to just using tar with gzip (as above) and also ZIP because you'll find a lot of those available as well.

2
  • 2
    @Jio because tar.gz is the defacto standard for UNIX. Since 1994 I have not found a single UNIX system, that this did not work on. Commented Nov 12, 2016 at 14:26
  • for some kind of files i found 7zip to make a really big difference. E.g. compressing a folder with javadoc the differece with a zip file is very big Commented Apr 9, 2018 at 13:00

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.