Help Docs Server Administration File Compression Algorithms

File Compression Algorithms

What's the difference between `.tar`, `.gz`, and `.tar.gz`? Our guide defines file compression and covers the most popular algorithms on Linux.

Use compression algorithms to reduce the size of your digital files and folders. The main goals of compression are to save storage space, speed up file transfers, and simplify file organization by bundling multiple files or folders into one archive.

In practice, compression allows you to:

  • Store more data on the same disk.
  • Transfer files faster over networks.
  • Organize multiple files, and/or folders into a single, portable package.
  • Preserve file attributes like permissions and ownership (when using archive tools like TAR)

Parameters / Features

FormatPurposeCompressionCommon OSNotes
TARBundles multiple filesNoneLinux/UnixNo size reduction; often used before compression
Gzip (.gz)Compresses single filesYes (Gzip)Linux/UnixUses DEFLATE algorithm
TAR.GZ / TGZBundles + compressesYes (Gzip)Linux/UnixCommon for backups
ZIPBundles + compressesYesWindows, Linux, MacWidely supported
BZ2 (.bz2)Compresses single filesYes (Bzip2)Linux/UnixBetter compression than Gzip but slower

Examples

TAR:

tar -cvf archive.tar my_folder
  •  Creates an archive with no compression.

Gzip:

gzip file.txt
  •  Compresses file.txt into file.txt.gz.

TAR.GZ:

tar -czvf archive.tar.gz my_folder
  •  Bundles and compresses a folder into one file.

ZIP:

zip -r archive.zip my_folder
  •  Creates a compressed zip archive.

Bzip2:

bzip2 file.txt
  •  Compresses a file with better ratios than Gzip.

Common Use Cases

  • Backups: Archiving folders into .tar.gz or .tgz files.
  • Cross-platform sharing: Using .zip for compatibility across Windows, macOS, and Linux.
  • Disk space savings: Compressing large log files with Gzip or Bzip2.
  • Data transfer efficiency: Sending compressed files over the internet to reduce upload/download times.

How to Use Tar, GZIP, & Zip in Linux

https://man7.org/linux/man-pages/man1/tar.1.html

https://www.gnu.org/software/gzip/manual/gzip.html

Was this article helpful?