File compression formats

There are as many different file archive and compression formats as there are religions. Nor does the comparison stop there, as you will discover if you ask a partisan for his opinion.

.bz2
A file compressed with bzip2. Open source; common on Linux systems. Provides high compression and is my choice for compressing a single file. References: man bzip2, bunzip2.

  • To compress: bzip2 -z input
  • To decompress: bunzip2 file.bz2

.gz
A file compressed with gzip. Open source; common on Linux systems. Computationally less intensive than bz2. References: man gzip, gunzip.

  • To decompress: gunzip file.gz

.tar
An uncompressed archive of multiple files. Open source; common on Linux systems. It has many options specific to backup and other archival uses. A tar archive can and often should be compressed (see below). Tar archives, whether compressed or uncompressed, are commonly called tarballs. Reference: man tar.

  • To create: tar -cf archive.tar input1 input2 …
  • To extract: tar -xf archive.tar

.tar.bz2, .tbz, .tb2
A compressed tar archive, made by first tarring and then bzipping. My choice for compressing multiple files into a single package. Reference: man tar.

  • To create: tar -cjf archive.tbz input1 input2 …
  • To extract and decompress: tar -jxf archive.tbz

.tar.gz, .tgz
A compressed tar file, made by first tarring and then gzipping. A common format for distributing source code. Reference: man tar.

  • To create: tar -czf archive.tgz input1 input2 …
  • To extract and decompress: tar -zxf archive.tar.gz

.zip
An archive compressed with any of a number of not always compatible open source or proprietary tools. Most common on Windows. On Linux there are the open source commands zip and unzip. Gives poor compression compared to other formats and isn’t any faster. Recovery options for damaged files are limited. I use it only to decompress those archives that happen to come in that format. References: man zip, unzip.

  • To decompress: unzip file.zip
  • To decompress, overwriting existing files without prompting: unzip -o file.zip
  • To test a package’s integrity before decompression: unzip -t file.zip (this option cannot be combined with decompression)
  • To attempt to fix a damaged zip archive: zip -F broken.zip –out maybefixed.zip. If no joy, try zip -FF broken.zip –out maybefixed.zip. If both fail, you’re out of luck.

REFERENCES
All formats have a bewildering array of options, so if you have a special need, consult the respective man page.

These notes were last updated on 17 July 2015.

Advertisements

About Warren Post

So far: Customer support guy, jungle guide, IT consultant, beach bum, entrepreneur, teacher, diplomat, over-enthusiastic cyclist. Tomorrow: who knows?
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

2 Responses to File compression formats

  1. Pingback: Installing and configuring Joomla | Warren's tech notes

  2. Pingback: Updating Joomla 1.0 and 1.5 | A maze of twisty little passages

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s