Monday, September 03, 2001

Compressing files

Although nowadays computers come with lots of disk space, more than a regular user will ever need, some times it is good to be able to compress files to save disk space. That will give you more space for movies and other stuff :-) And many utilites are able to read and operate on compressed files, so it does not make a difference to daily usage. Below are a few ways of compressing files.

  1. gzip, the GNU "zip" facility: use it as tt. Creates a compressed file with the name file-name.gz (original file is removed). Uncompress with gunzip file-name.gz
  2. bzip or bzip2: the command is bzip2 file-name; the compressed file will be called file-name.bz or file-name.bz2 (original file is deleted). Uncompress with bunzip2 file-name.bz2
  3. tar: to archive lots of files, use as

    tar tar-file.tar file1 file2 file3 ….

    Will put the files file1 file2 file3 … in a single archive file called tar-file.tar, without removing the original files (although you should delete them since, after all, you are trying to save disk space). The files in the archive can be extracted with the following command:

    tar xkvf tar-file.tar
  4. tar and gzip: you can use gzip to compress a tar file, obtaining a file called something like tar-file.tar.gz. You can extract the individual files in the archive with this command:

    tar zxkvf tar-file.tar.gz
    zip: the utility quite used in Windows machines, similar to tar just mentioned. You create zipped files with

    zip file.zip file1 file2 file3 …

    and recover the original files (which, again, you should have deleted) with



    unzip file.zip

    tar -tvf filename will list the files under .tar

I will explain in a future posts a little more about tar and perhaps another archiving utility, ar, but now time to work on something else.