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).
- 1Linux Top 3: Fedora 24, Peppermint 7 and Solus 1.2
- 2Linux Top 3: Alpine Linux 3.4, deepin 15.2 and Linux Lite 3.0
- 3Linux 4.7 Set to Boost Live Patching, Security and Power Management
- 4Linux 4.6 Charred Weasel adds USB 3.1 Support
- 5Linux Top 3: OpenIndiana 2016.04, Ubuntu 16.04 and Debian's New Leader