Sending and receiving large files and pictures over the internet is a headache many times. Compression and decompression tools are meant to address this problem. Lets take a quick overview of a few open source tools that are available to make our jobs simpler.
Tar
gzip, gunzip
bzip2, bunzip2
7-Zip
### Tar ###
Tar is derived from 'Tape archiver' as this was initially used for archiving and storing files on magnetic tapes. It is a GNU software. It can compress a set of files (archives), extract them and manipulate those which already exist. It is useful for storing, backing up and transporting files. Tar can preserve file and directory structure while creating the archives. Files archived using tar have '.tar' extensions.
Basic Usage
#### a) Creating an archive (c / --create) ####
tar --create --verbose --file=archive.tar file1 file2 file3
Refer to [tar home page][1] for its detailed usage
### Gzip / Gunzip ###
Gzip stands for GNU zip. It is a compression utility that is commonly available in Linux operating system. Compressed files have an extension of '*.gz'
Using '-d' option with gzip command has the same effect of gunzip on compressed files.
More details can be obtained from [gzip home page][2]
### Bzip2 / Bunzip2 ###
[Bzip2][3] is also a compression tool like gzip but can compress files to smaller sizes than that is possible with other traditional tools. But the drawback is that it is slower than gzip.
**Basic Usage**
#### a) File Compression ####
Generally, no options are used for compression and the files to be compressed are passed as arguments. Each file gets compressed individually and compressed files will have the extension 'bz2'.
bunzip2 can decompress files with extensions bz2, bz, tbz2 and tbz. Files with tbz2 and tbz will end up with '.tar' extension after decompression.
bzip2 -dc performs the function of decompressing files to the stdout
### 7-zip ###
[7-zip][4] is another open source file archiver. It uses 7z format which is a new compression format and provides high-compression ratio. Hence, it is considered to be better than the previously mentioned compression tools. It is available under Linux as p7zip package. The package includes three binaries – 7z, 7za and 7zr. Refer to the [p7zip wiki][5] for differences between these binaries. In this article, we will be using 7zr to explain the usage. Archived files will have '.7z' extension.
**Basic usage**
#### a) Creating an archive ####
7zr a archive-name.7z file-name(s) / directory-name(s)