Archiving with Gzip and Tar
The best archiving tool to use on Linux is probably Gzip. By best, it is a format that everyone else using Linux can understand, and it is better at compressing files that the older compress command. A newer format called bzip2 has better compression rates but apparently not everyone can understand the format. Admittedly, that’s according to my 1999 edition of Running Linux but it’s certainly true that I’ve seen lots of Gzip (.gz) files, but can’t remember seeing any bzip2 (.bz2) files.
The gzip command compresses a file, the gunzip command uncompresses a file and the following command tells you how compressed a file is:
gzip -l filename.txt.gz
One quirk compared with the Zip archive commonly found on Windows and the Mac is that a .gz archive merely contains one file. As such, you will commonly find gzip archives called things like filename.txt.gz (it contains a single text file). To compress a whole range of files, you have to use an extra command called tar (stands for tape archive). Tar does no compression on its own: it simply lumps a selection of files into a single file for easy transportation. Once files are part of a Tar file, you use gzip to compress the tar and end up with a file looking something like backup.tar.gz.
Or you can cheat and use the z option, as in:
tar czvf home.tar.gz /home
This puts the home directory into a tar archive, compressed by gzip.
Filed under: Archiving and backups | Leave a Comment
No Responses Yet to “Archiving with Gzip and Tar”