Tutorial: Multithreaded Folder Compression for the XFCE Desktop

Have you ever made a “zip file” and wished it didn’t take so long? So have I! If you’re a fellow GNU/Linux user and your computer has a multi core CPU, here’s something you can do to dramatically speed up the creation of a basic zip file.

Most computers these days have multiple cores and are capable of doing many tasks simultaniously (unlike me!). This is typically refered to as multithreading or parallelization. Not all workloads can be parallelized, but things like compressing files and video transcoding are just stupidly awesome for it!

To make the most of my 8 core AMD FX-8320 CPU, which is an amazing (and inexpensive) CPU for multithreaded workloads, I learned how to use the multithreaded version of gzip to compress folders. The results were so great, I decided to make this tutorial!

– Linux Mint / Ubuntu / Debian (for apt-get)
– XFCE Desktop Environment
– Thunar File Manager
– pigz

1. Downloads pigz (Parallel Implimentation of Gzip).

sudo apt-get install pigz

2. Replace gzip with pigz.
A. Rename gzip.
B. Make a symbolic link from gzip to pigz.

sudo mv /bin/gzip gzip.original
sudo ln -s /bin/gzip /usr/bin/pigz

3. Create a new script file in your home folder (I put mine in a scripts folder).
A. Open Thunar, right click > Create Document > Empty File
B. Name the file thunarzip.sh
C. Right click the new file > Properties > Permissions Tab > Check “Allow this file to run as a program”
D. Open the file and paste the following into it:

# Compress a folder using Thunar's right click menu
# and give it the date in the name.
now=`date +"%Y-%m-%d"`
tar -cvzf $1_$now.tar.zip $1

4. Open Thunar and go to Edit > Configure custom actions…

5. Click the + (plus sign) to make a new action and enter the information below and click OK when you’re finished.
Name: Compress Folder
Description: Compress the folder here
Command: /Path/Where/You/Saved/File/./thunarzip.sh %n
Icon: Click the button and choose one you like!

6. Now go compress something!

7. Enjoy the results!

For more information on Thunar custom actions, including many handy ones you might like to use as well, check this out: