Using a compression tool is not a new thing to talk about. Since you’re using a Linux distribution, you probably already know a lot of kinds of stuff about compressing files. Mostly, in server-level works, you might need to make files smaller or change the file type. On that occasion, using a compression tool might really help to save time. In the world of compression, the Pigz tool is a handy and easy-to-use compression tool for Linux. It’s easy to install and use the Pigz tool in all major Linux distributions.
Install and Use Pigz in Linux
In the world of Linux, the Pigz stands for parallel gzip (GNU ZIP). Most Linux users use the Pigz tool for faster and speedy compression. The tool is written by using the most common and used zipping library functions. You can use it for compression and decompression.
The Pigz tool is often used for running multiple operations at a time using 4 CPU threads so that it can balance the CPU load. After you finish the compression, it also maintains the output order so that you don’t get confused about the output files. In this post, we will see how to install and use the Pigz tool in Linux.
Step 1: Install Pigz tool on Linux
Installing the Pigz tool in a Linux system is easy and hassle-free. Here, I am going to describe the installation method of Pigz for all major Linux distributions. We will be using the default package management command for each distribution.
Please choose the right command according to your distribution. Before executing the commands, make sure that you have an active internet connection and you own the root access on your system.
- Install Pigz on Debian/Ubuntu Linux
$ sudo apt-get install pigz
- Get the Pigz tool on Fedora and Red Hat Linux
$ sudo yum install pigz
- The following command will install Pigz on Arch-based Linux
$ sudo pacman -S pigz
- Install Pigz on SuSE and openSuSE Linux
$ sudo zypper install pigz
Step 2: Compress Files with Pigz on Linux
After we finish installing the Pigz tool on Linux, it’s time to run the tool. Here, we will see a few quick demonstrations of the Pigz command on the terminal shell. The following command will allow you to compress an ISO file into your system.
Here, I am using a Fedora ISO file to compress via Pigz. Please note that the below command will remove the original file and only keep the compressed file.
sudo pigz Fedora-Workstation-Live-x86_64-34-1.2.iso
You can browse the compressed file by using the following ls command.
ls -l Fedora-Workstation-Live-x86_64-34-1.2.iso.gz
In case you need to keep both original and compressed files, execute the following Pigz command on the shell. But, please note that it may take a little longer to finish than the previous command.
$ sudo pigz -k Fedora-Workstation-Live-x86_64-34-1.2.iso
Installing the Pigz tool on Linux also allows you to see the full table of contents of the file that you are compressing by the Pigz tool.
$ sudo pigz -l Fedora-Workstation-Live-x86_64-34-1.2.iso.gz
An interesting fact about Pigz is, it allows you to compress an entire directory through the CLI mode.
$ sudo tar cf – pay/ | pigz > NEWDIR.tar.gz
You can execute any of the following commands to decompress a file on Linux through Pigz.
$ sudo pigz -d Fedora-Workstation-Live-x86_64-34-1.2.iso.gz
$ sudo unpigz Fedora-Workstation-Live-x86_64-34-1.2.iso.gz
Step 3: Get to Know the Compression Rate on Pigz
The Pigz is a wonderful handy tool for compressing files and folders. Since it allows to use of CPU threads that kind of figure out how much speed and time it will consume, so here are some commands that you can use to get the best compression.
After we install the Pigz tool on Linux, we can choose to get the best quality compression, but it will take a little longer than the regular compression. Please use the following command with the flag -9 to get the best compression.
$ sudo pigz -9 Fedora-Workstation-Live-x86_64-34-1.2.iso
To get a quick output in a low-quality compression, execute the following command on your terminal shell.
$ sudo pigz -1 Fedora-Workstation-Live-x86_64-34-1.2.iso
In Linux, the Pigz compression tool also allows you to only change the file type to zip without actually compressing the file. The following command shows how you can use a -0 flag to zip a file.
$ sudo pigz -0 Fedora-Workstation-Live-x86_64-34-1.2.iso
The system default compression is the -6 flag that gives a standard compressed file in output.
$ sudo pigz -6 Fedora-Workstation-Live-x86_64-34-1.2.iso
Since we already mentioned using multiple CPU threads for Pigz on Linux, here is the command that you can execute to use 4 CPU threads to make the compression faster.
$ sudo pigz -9 -k -p4 Fedora-Workstation-Live-x86_64-34-1.2.iso
Step 4: Change Compression Format with Pigz
Usually, In Linux, the Pigz provides an output file with the
.gz file extension that says that the file is compressed by the GNU zip tool. However, it’s not surprising that you might need to change the file format.
Please use the following command to change the
.GZ file type to
.zz file. Once you install and use the Pigz tool on Linux, you will see that using the Pigz tool is a wise decision for compressing any type of file.
$ sudo pigz -k -z Fedora-Workstation-Live-x86_64-34-1.2.iso
The next command would be the one that you might have been looking for a while. Yes, Zip; the below-mentioned command will let you change the output file format to zip.
$ sudo pigz -k -K Fedora-Workstation-Live-x86_64-34-1.2.iso
Playing with the Pigz compression tool on Linux is really easy and straightforward. In the entire post, we have seen the methods of installing the Pigz compression tool on Linux and a few features and use-case. If you’re still confused about using the Pigz tool, please open the Pigz manual page or the help page by using the
man pigz or
pigz --help command on the Linux terminal.
Please share it with your friends and the Linux community if you find this post useful and informative. You can also write down your opinions regarding this post in the comment section.