A compressed file gathers several files or folders into one package and usually makes them smaller. Common formats are zip, rar, 7z and tar.gz. To see the contents you have to "extract" it.

How does the size shrink?#

Algorithms store repetition in a short form. For example, if a sentence is repeated 50 times in a text, it is written once and the rest are references. That is why text and data files compress a lot, but jpg photos and video, which are already compressed, do not shrink much.

Two kinds of compression#

  • Lossless: after extraction you get exactly the original file (like zip).
  • Lossy: sacrifices a little quality (like mp3 and jpg).

An example#

To send a website folder to a client, you zip it so it becomes a single file. A WordPress backup is usually a compressed file too.

Notes#

  • You can encrypt a compressed file.
  • 7-Zip is a free, open-source program that reads all the main formats.
  • Do not open an unknown compressed file without checking; it may hold a malicious executable.
  • A "zip bomb" is a small file that produces a huge amount of data when extracted and crashes the system; do not open unknown files.