Lecture # 19 - File Compression and Archiving

Lecture # 19 - File Compression and Archiving

File Compression and Archiving in Linux

File Compression:

File compression is a process of reducing the size of a file. File compression is always performed using a lossless compression algorithm. This means no information is lost during the compression process. A compress archive can be fully restored to the original version when it is decompressed.

  • Compression:

  1. gzip:

To compress a file using gzip, gzip [file-name] is used.

  1. bzip2:

To compress a file using bzip2, bzip2 [file-name] is used.

  • Decopression:

  1. gunzip:

    To decompress a gzip file, gunzip is used. This command is written as

    gunzip [file-name].gz .

  2. bunzip2:

To decompress a bzip2 file, bunzip2 is used. This command is written as

bunzip2 [file-name].bz2 .

File Archiving:

Archiving is the process of gathering up many files and bundling them together into a single large file. There are two ways to archive the files.

  • Archiving:

    1. tar:

To create an archive using tar, tar -cf [archive-name.tar] [file/directory1] [file/directory2] is used.

  1. zip:

To create an archive using zip, zip -r [archive-name.tar] [file/directory1] [file/directory2] is used.

  • Unarchiving:

  1. tar:

To unarchive using tar, tar -xf [name] is used.

  1. zip:

    To unarchive using zip, unzip [name] is used.