4 Archiving Tools for Linux Server Admins - page 2
tar and zip
gzip does file compression/decompression, but not archiving. However, it works well when used together with an archiving tool - in particular, gzip and tar play nicely together.
- gzip file.tar
compresses file.tar to create file.tar.gz.
- tar czf file.tar.gz mydir/
archives and compresses mydir/ to create file.tar.gz
- gunzip file.tar.gz or gzip -d file.tar.gz
- tar zxf file.tar.gz
uncompress file.tar.gz and also unpack the archive.
Note that you can also use gzcat (use exactly as gunzip) to decompress directly to standard output.
bzip2, like gzip, does compression but not archiving. Again, it works well with tar if you want both archiving and compression. It compresses better than gzip, but the cost of that is that it takes longer to run.
It uses a series of stacked transforms to compress data, the most important of which is the Burrows-Wheeler transform. This reorders blocks to maximise the number of repeated symbols. Runs of repeated symbols can then be replaced by the symbol and a code which represents the length of the run, reducing the size taken up by each run. The Huffman coding used in DEFLATE (where common symbols are swapped in for shorter versions of them) is also used after that, to reduce the space still further, along with a couple of other more minor changes. Given all of that, the time it takes is hardly surprising!
- bzip2 file.tar
compresses file.tar to create file.tar.bz2.
- bunzip2 file.tbz
uncompresses file.tbz to create file.tar.
- tar jxf file.tbz
uncompresses file.tbz and unpacks the archive.
Note that you can also use bzcat to decompress directly to standard output.
If you're interested in compression algorithms, you could also check out 7-zip (the Linux command-line version is p7zip), which implements the LZM algorithm. In most cases it compresses better than bzip2, and it also decompresses faster (although it compresses slower). However, it's much less popular (I've never seen it in the wild).
Sponsored by BlackBerry
BlackBerry® Enterprise Server Express enables businesses of any size to quickly and easily get started with the BlackBerry solution. It provides advanced BlackBerry smartphone features with no additional software or user license fees, and works with any Internet-enabled BlackBerry data plan or a BlackBerry enterprise data plan. Download now!