In this video, we'll zoom into compression a little bit more.
So in most cases, compression will be simply done by using the TAR utility.
There's a couple of options, and each of these options run as a separate command as well.
There is gzip, which is minus Z in tar, which is the most common compression utility.
It's very fast and it has a reasonable compression rate.
Bzip2 or minus lowercase j in tar is an alternative utility.
It's offering better compression and it's only a tiny little bit slower.
And there is xz, which is minus uppercase j in tar,
yet another utility offering the best compression, but really significantly slower.
Now, the main difference between these is the compression ratio and the time that it takes to compress.
And if you want to verify how it is working, use a time utility to measure the time that it takes.
Now, time is an internal command, but there is also bin slash time. And because internal commands
have precedence, use bin slash time. If you want to see more details, let me show you.
So let me use time, tar,
cvf etc 2 tar, etc.
I just want to do everything again so that we can clearly compare the time that it takes.
So here the time utility is showing that the real time was 0.268 seconds.
And of that time we spent 0.07 seconds in user space and 0.15 seconds in system space.
System space is the time that the operating system is really busy dealing with
the command. And user space is the time that is spent in user space.
That is when no drivers are involved and just other work is done.
Now what is happening? If we are going to compress that using
gzip, let's make that TAR GZ so that you can clearly compare.
As you can see, the amount of time has more than doubled.
Now how about we make that bzip2.
There we go again. Double the time.
And you can probably guess what is going to happen if you do it using XZ.
As you can see, that is more than four times the time it
took in bzip2, which is a very clear explanation why XZ, even if
it is very efficient, is is not the most commonly used utility.