Linux users are blessed with many effective and reliable file compression utilities at their disposal.
The majority of utilities listed here work well with all the Linux distros, and we have tested them on Ubuntu.
tar
The tar file compression is one of the most widely used file compression utilities on Linux. File compressed with this utility have suffix .tar.gz and .tgz, and they are also called tarballs.
For example, if we have a file/directory named swap1 in the current directory. To save it to a compressed file named file.tar,gz, we have to run the following command in terminal:
You might be wondering what does exactly switch -czvf means, let’s see it one-by-one.
-c : Create an Archive
-z : Compress Archive with gzip
-v : known as “verbose”. It displays the progress in the terminal window when the archive is being created.
-f : This switch allows you to specify the file name of the archive.
Install it by running the following command in the terminal:
gzip
The gzip stands for GNU Zip, and it is an open-source file compression format used to compress single files. It produces zipped files with the suffix .gz extension.
ZIP and GZIP, are both very popular file compression formats when it comes to saving space and reducing the time required to send the file over the internet.
Here is its basic syntax:
Using switch -l will give you detailed information about the compressed file.
To unzip a file use syntax:
To install gzip, run the following command in the terminal:
7zip
The 7zip is an open-source file compression utility that was initially developed for Windows users and was later ported to other operating systems like Linux and its distros. It supports multiple file compression formats and is popular for a high compression ratio with LZMA and LZMA2 compression techniques.
Syntax:
To extract:
To install 7zip, run the following command in the terminal:
lzma
The lzma is another file compression utility like zip or tar, and it ships-in pre-installed with Linux and its distros. It is quite a fast file compression utility as compared to others.
To create archive:
To extract files:
bzip2
The bzip2 is a free and open-source file compression utility. It is a faster file utility as compared to gzip but can only compress a single file at a time.
Syntax:
This technique uses more RAM during compression. To reduce its use, switch –s, as shown below:
To extract:
xz file compression
The xz is an upgrade to the lzma file compression utility but can only compress a single file at a time. It integrates well with all the Linux distros, even the older releases.
Syntax to compress:
Syntax to extract:
shar
The shar, short for “shell archive”, is a simple and reliable file compression utility for personal and power users.
Syntax to compress:
Syntax to extract:
To install shar, run the following command in the terminal:
ar
The ar is a widely used file compression utility in Debian and its derivatives.
Syntax to compress:
Syntax to extract:
kgb
The kgb is free to use file compression utility with support for the majority of file formats. It supports archiving multiple files into one with a high compression ratio.
Syntax to archive:
Syntax to decompress:
To install kgb, run the following command in the terminal:
pax
The pax stands for Portable Archive Exchange, and it is a file compression utility used in creating and extracting archives. It supports various file compression formats like tar, cpio, bcpio, and ustar.
Syntax to compress:
Syntax to decompress:
To install pax, run the following command in the terminal:
So, these are the top 10 file compression utilities for Linux and its distros. There are still other compression utilities for Linux, but these 10 are the standouts when tested on various parameters. Feel free to share your views with us at @linuxhint and @SwapTirthakar.