Docs / Linux Basics / How to Work with Linux Archives: zip tar gz bz2 xz

How to Work with Linux Archives: zip tar gz bz2 xz

By Admin · Mar 1, 2026 · Updated Apr 23, 2026 · 27 views · 2 min read

Why Archives Matter

Archives bundle multiple files into a single package for transfer, backup, or distribution. Understanding the common archive formats on Linux helps you efficiently manage files on your Breeze.

tar (Tape Archive)

The most common Linux archive tool. By itself, tar bundles files without compression:

# Create a tar archive
tar cf backup.tar /var/www/html

# Extract a tar archive
tar xf backup.tar

# List contents without extracting
tar tf backup.tar

gzip (.tar.gz or .tgz)

Fast compression with good ratios. The most popular Linux combination:

# Create compressed archive
tar czf backup.tar.gz /var/www/html

# Extract
tar xzf backup.tar.gz

# Compress a single file
gzip largefile.log
# Produces largefile.log.gz, removes original

# Decompress
gunzip largefile.log.gz

bzip2 (.tar.bz2)

Better compression ratio than gzip but slower:

# Create bzip2 archive
tar cjf backup.tar.bz2 /var/www/html

# Extract
tar xjf backup.tar.bz2

xz (.tar.xz)

Best compression ratio, slowest speed. Ideal for distribution:

# Create xz archive
tar cJf backup.tar.xz /var/www/html

# Extract
tar xJf backup.tar.xz

zip

Cross-platform format, widely compatible:

# Create zip archive
zip -r backup.zip /var/www/html

# Extract
unzip backup.zip

# List contents
unzip -l backup.zip

# Extract to specific directory
unzip backup.zip -d /tmp/restored

Quick Reference

  • Fastest: gzip -- use for routine backups
  • Best ratio: xz -- use for archival or distribution
  • Cross-platform: zip -- use when sharing with non-Linux users
  • Balanced: bzip2 -- between gzip and xz in speed and ratio

Was this article helpful?