Zip, Archive and Compress tools in Linux

Here are the different apps in linux for compressing and archiving files.

Definitions:

Tarball: A tarball is a collection of multiple files in Linux stored as a single file. The term tarball comes from the coal-based sealant used during construction works. A tarball is often simply called a TAR file, which stands for Tape Archive. This is because the TAR filetype was originally created to store data in magnetic tapes.

Gzip: GNU gzip is a file compression algorithm used to compress files. The file extension for gzip is GZ and therefore, you can deduce that any file ending with GZ has been compressed using the gzip algorithm.

TAR.GZ: A TAR.GZ file is a version of a tarball compressed with the gzip algorithm. TAR is the file extension for tarballs, whereas GZ denotes gzip. The TGZ file extension is also used sometimes instead of TAR.GZ.

Bzip2: Similar to gzip, several other file compression algorithms are also available, including bzip2. When you compress a TAR file using bzip2, the output file will have either of the following extensions: TAR.BZ2, TAR.BZ, or simply TBZ.

How to Create TAR and TAR.GZ Files

Using the tar Utility
The basic syntax to create compressed tarballs using the tar command is:

$ sudo tar -cvzf archive filename
$ sudo tar -cvzf archive directory

Note that you need to pass the file extension (TAR or TAR.GZ) in the archive name as follows:

$ sudo tar -cvzf new.tar.gz big-file.txt
$ sudo tar -cvf new.tar big-file.txt

To archive and compress the /Documents directory using tar:

$ sudo tar -cvzf new.tar.gz ~/Documents

You can also compress multiple directories and files by creating a single tarball. To do so:

$ sudo tar -cvzf new.tar.gz ~/Documents ~/Downloads file1.txt file2.txt

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.