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.
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
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
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
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
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.
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.