1 00:00:06,540 --> 00:00:09,470 In this video, we'll zoom into compression a little bit more. 2 00:00:10,609 --> 00:00:14,529 So in most cases, compression will be simply done by using the TAR utility. 3 00:00:16,129 --> 00:00:20,359 There's a couple of options, and each of these options run as a separate command as well. 4 00:00:20,940 --> 00:00:26,480 There is gzip, which is minus Z in tar, which is the most common compression utility. 5 00:00:26,989 --> 00:00:29,809 It's very fast and it has a reasonable compression rate. 6 00:00:31,989 --> 00:00:37,420 Bzip2 or minus lowercase j in tar is an alternative utility. 7 00:00:37,960 --> 00:00:41,289 It's offering better compression and it's only a tiny little bit slower. 8 00:00:42,189 --> 00:00:46,509 And there is xz, which is minus uppercase j in tar, 9 00:00:46,509 --> 00:00:50,829 yet another utility offering the best compression, but really significantly slower. 10 00:00:51,929 --> 00:00:56,869 Now, the main difference between these is the compression ratio and the time that it takes to compress. 11 00:00:58,049 --> 00:01:03,009 And if you want to verify how it is working, use a time utility to measure the time that it takes. 12 00:01:04,290 --> 00:01:10,140 Now, time is an internal command, but there is also bin slash time. And because internal commands 13 00:01:10,140 --> 00:01:15,989 have precedence, use bin slash time. If you want to see more details, let me show you. 14 00:01:17,450 --> 00:01:22,545 So let me use time, tar, 15 00:01:22,545 --> 00:01:27,640 cvf etc 2 tar, etc. 16 00:01:28,219 --> 00:01:33,840 I just want to do everything again so that we can clearly compare the time that it takes. 17 00:01:34,560 --> 00:01:37,480 So here the time utility is showing that the real time was 0.268 seconds. 18 00:01:40,099 --> 00:01:45,530 And of that time we spent 0.07 seconds in user space and 0.15 seconds in system space. 19 00:01:49,840 --> 00:01:54,400 System space is the time that the operating system is really busy dealing with 20 00:01:54,400 --> 00:01:58,960 the command. And user space is the time that is spent in user space. 21 00:01:59,819 --> 00:02:04,719 That is when no drivers are involved and just other work is done. 22 00:02:05,579 --> 00:02:09,719 Now what is happening? If we are going to compress that using 23 00:02:09,719 --> 00:02:13,860 gzip, let's make that TAR GZ so that you can clearly compare. 24 00:02:14,900 --> 00:02:18,419 As you can see, the amount of time has more than doubled. 25 00:02:19,199 --> 00:02:22,360 Now how about we make that bzip2. 26 00:02:29,439 --> 00:02:31,430 There we go again. Double the time. 27 00:02:31,990 --> 00:02:37,000 And you can probably guess what is going to happen if you do it using XZ. 28 00:02:38,360 --> 00:02:43,083 As you can see, that is more than four times the time it 29 00:02:43,083 --> 00:02:47,806 took in bzip2, which is a very clear explanation why XZ, even if 30 00:02:47,806 --> 00:02:52,530 it is very efficient, is is not the most commonly used utility.