1 00:00:06,840 --> 00:00:07,673 - In this video, 2 00:00:07,673 --> 00:00:10,200 we are going to explore how to work with packages 3 00:00:10,200 --> 00:00:11,743 using YUM and DNF. 4 00:00:13,022 --> 00:00:15,750 YUM and DNF are specific for Red Hat. 5 00:00:15,750 --> 00:00:19,740 And YUM is using all the versions of Red Hat and family. 6 00:00:19,740 --> 00:00:22,893 The YUM backend recently has been replaced with DNF. 7 00:00:23,790 --> 00:00:27,630 DNF is a preferred tool in current RHEL versions. 8 00:00:27,630 --> 00:00:30,540 But as of now, DNF, as well as YUM, 9 00:00:30,540 --> 00:00:33,930 are basically providing the same functionality. 10 00:00:33,930 --> 00:00:35,550 And that is because both commands 11 00:00:35,550 --> 00:00:38,850 are using a symbolic link to the same binary. 12 00:00:38,850 --> 00:00:40,650 So if you wanna be cool, 13 00:00:40,650 --> 00:00:44,223 you should use DNF utility, but really it doesn't matter. 14 00:00:45,060 --> 00:00:46,950 Now DNF uses repositories. 15 00:00:46,950 --> 00:00:48,480 And the repositories by default 16 00:00:48,480 --> 00:00:52,500 are in the directory /etc/yum.repos.d. 17 00:00:52,500 --> 00:00:54,570 These are text based configuration files 18 00:00:54,570 --> 00:00:57,063 in which you configure your repositories. 19 00:00:57,960 --> 00:01:01,263 The dnf command was really written to be intuitive. 20 00:01:02,160 --> 00:01:05,430 Like you want to install a package, dnf install. 21 00:01:05,430 --> 00:01:08,790 You want to look up a package, dnf search. 22 00:01:08,790 --> 00:01:11,223 You want to remove it, dnf remove. 23 00:01:12,570 --> 00:01:15,300 DNF also allows working with package groups 24 00:01:15,300 --> 00:01:18,930 to make installation of specific functionality easier. 25 00:01:18,930 --> 00:01:20,460 So if you work with a package group, 26 00:01:20,460 --> 00:01:23,040 you don't have to focus on individual packages. 27 00:01:23,040 --> 00:01:25,320 You focus more on functionality. 28 00:01:25,320 --> 00:01:28,350 So you would use dnf groups list for a list of groups. 29 00:01:28,350 --> 00:01:30,270 and then you can install the complete group 30 00:01:30,270 --> 00:01:32,223 using dnf groups install. 31 00:01:33,210 --> 00:01:35,010 There is also yum modules. 32 00:01:35,010 --> 00:01:36,660 yum modules provide a way 33 00:01:36,660 --> 00:01:39,300 to install different versions of packages, 34 00:01:39,300 --> 00:01:42,930 including all of the required dependencies. 35 00:01:42,930 --> 00:01:46,350 In order to work with modules, you use yum module install 36 00:01:46,350 --> 00:01:49,230 like yum module install container-tools. 37 00:01:49,230 --> 00:01:51,270 And the cool thing about these modules 38 00:01:51,270 --> 00:01:54,990 is that the Red Hat family distribution, by using modules, 39 00:01:54,990 --> 00:01:59,520 is capable of providing different versions of vital packages 40 00:01:59,520 --> 00:02:02,190 like Python and Pearl, for instance. 41 00:02:02,190 --> 00:02:04,200 You wanna use Python 3.6? 42 00:02:04,200 --> 00:02:07,470 Use the yum module for Python 3.6. 43 00:02:07,470 --> 00:02:08,850 You wanna use 3.8? 44 00:02:08,850 --> 00:02:11,433 Use the yum module for Python 3.8. 45 00:02:12,810 --> 00:02:15,540 Now, if you are working with YUM and DNF, 46 00:02:15,540 --> 00:02:19,440 then it might be convenient to find the right package. 47 00:02:19,440 --> 00:02:21,120 Sometimes that's not that easy. 48 00:02:21,120 --> 00:02:22,590 Sometimes dnf search 49 00:02:22,590 --> 00:02:24,780 doesn't give you the package that you need. 50 00:02:24,780 --> 00:02:26,880 Then it's good to know, that as an alternative, 51 00:02:26,880 --> 00:02:29,340 you can use dnf provides. 52 00:02:29,340 --> 00:02:33,570 dnf provides allows you to search on a file name. 53 00:02:33,570 --> 00:02:35,040 That can be any file name. 54 00:02:35,040 --> 00:02:38,280 Specify the file name using */, name of the file. 55 00:02:38,280 --> 00:02:40,710 And you will see the matching package. 56 00:02:40,710 --> 00:02:42,870 And also nice is dnf history. 57 00:02:42,870 --> 00:02:46,770 That allows you to undo changes recently applied 58 00:02:46,770 --> 00:02:49,170 by using these packages. 59 00:02:49,170 --> 00:02:51,020 Let me show you how to work with YUM. 60 00:02:53,760 --> 00:02:54,593 All right. 61 00:02:54,593 --> 00:02:59,420 Let me use sudo yum search, search what? 62 00:03:00,690 --> 00:03:04,800 Well, let's do nmap for instance, and there we go. 63 00:03:04,800 --> 00:03:08,340 If you do sudo yum search, we get a result like this. 64 00:03:08,340 --> 00:03:12,120 So nmap, this is the nmap that was found. 65 00:03:12,120 --> 00:03:16,370 Network exploration tool and security scanner. 66 00:03:16,370 --> 00:03:20,608 That's a description that we've got about nmap. 67 00:03:20,608 --> 00:03:22,168 Then we have nmap-ncat. 68 00:03:22,168 --> 00:03:23,310 What is that? 69 00:03:23,310 --> 00:03:25,860 That is another package that was found. 70 00:03:25,860 --> 00:03:27,840 So we have a name, exact match, 71 00:03:27,840 --> 00:03:29,640 and we have a name and summary match. 72 00:03:29,640 --> 00:03:31,980 So the exact match is the most likely, 73 00:03:31,980 --> 00:03:34,533 the name and summary is a little bit less likely. 74 00:03:35,460 --> 00:03:37,290 So use this on anything, 75 00:03:37,290 --> 00:03:39,990 but sometimes if you use yum search, 76 00:03:39,990 --> 00:03:42,990 I'm using yum search seinfo, for instance. 77 00:03:42,990 --> 00:03:44,010 Now, what do we get? 78 00:03:44,010 --> 00:03:46,773 We get a No matches found. 79 00:03:47,760 --> 00:03:49,380 That is because yum search 80 00:03:49,380 --> 00:03:52,410 is not doing a deep inspection of your packages. 81 00:03:52,410 --> 00:03:56,310 If I want to search for packages containing a file 82 00:03:56,310 --> 00:03:58,380 then I should do two things. 83 00:03:58,380 --> 00:04:02,700 First, I need to replace the seinfo with */seinfo. 84 00:04:02,700 --> 00:04:04,740 That's a mandatory pattern. 85 00:04:04,740 --> 00:04:07,350 And next I can use provides. 86 00:04:07,350 --> 00:04:11,490 So sudo yum provides or dnf provides if you want to. 87 00:04:11,490 --> 00:04:14,490 And then we see that setools-console 88 00:04:14,490 --> 00:04:17,340 is the package that we want to install. 89 00:04:17,340 --> 00:04:22,340 So I can use sudo yum info on setools-console 90 00:04:22,380 --> 00:04:24,030 to get more information. 91 00:04:24,030 --> 00:04:26,760 And there we go, a little bit more information. 92 00:04:26,760 --> 00:04:30,120 And if I decide that this is really what I want, 93 00:04:30,120 --> 00:04:35,120 then I'm going to use sudo yum install -y setools-console. 94 00:04:41,640 --> 00:04:43,470 So what is this -y about? 95 00:04:43,470 --> 00:04:44,550 Well, let me show you. 96 00:04:44,550 --> 00:04:48,603 I'm just going to not include the -y option. 97 00:04:49,440 --> 00:04:51,720 If you do not include the -y, 98 00:04:51,720 --> 00:04:54,108 then the command is prompting you 99 00:04:54,108 --> 00:04:56,190 about what it's going to do. 100 00:04:56,190 --> 00:04:58,440 And then it's asking you, is that okay? 101 00:04:58,440 --> 00:05:01,110 If you wanted to immediately install, 102 00:05:01,110 --> 00:05:02,730 then you can use the -y. 103 00:05:02,730 --> 00:05:05,220 It won't prompt, it'll just do the installation. 104 00:05:05,220 --> 00:05:07,623 And there we go, the package is installed. 105 00:05:08,670 --> 00:05:10,650 Let me do a sudo yum history 106 00:05:10,650 --> 00:05:13,200 to see what has recently happened. 107 00:05:13,200 --> 00:05:16,260 And there, we can see the history of packages 108 00:05:16,260 --> 00:05:20,160 that recently has been applied. 109 00:05:20,160 --> 00:05:24,930 Now with YUM, you can also do things like sudo yum upgrade. 110 00:05:24,930 --> 00:05:26,820 And yum upgrade is doing what? 111 00:05:26,820 --> 00:05:29,910 It's checking on all the packages currently installed. 112 00:05:29,910 --> 00:05:33,090 And, wow, we can see 681, 113 00:05:33,090 --> 00:05:36,240 and we can upgrade them if we want to. 114 00:05:36,240 --> 00:05:37,410 Do I really want that? 115 00:05:37,410 --> 00:05:39,000 No, I don't think so. 116 00:05:39,000 --> 00:05:42,360 681 megabytes, too much data traffic. 117 00:05:42,360 --> 00:05:44,820 I don't wanna do that right now. 118 00:05:44,820 --> 00:05:46,860 Now how about these yum groups? 119 00:05:46,860 --> 00:05:49,350 sudo yum groups list. 120 00:05:49,350 --> 00:05:50,183 There we go. 121 00:05:50,183 --> 00:05:52,560 We have the different yum groups. 122 00:05:52,560 --> 00:05:57,270 So if I wanted to install System Tools for instance, 123 00:05:57,270 --> 00:06:02,167 sudo yum groups install system, 124 00:06:02,167 --> 00:06:05,250 oh, system tools, 125 00:06:05,250 --> 00:06:07,650 what do you think, is that going to work? 126 00:06:07,650 --> 00:06:10,410 Well, I have my opinion about it, 127 00:06:10,410 --> 00:06:12,420 but let's just have a look. 128 00:06:12,420 --> 00:06:13,290 And what do we see? 129 00:06:13,290 --> 00:06:15,810 We see module or group system is not available. 130 00:06:15,810 --> 00:06:18,780 Module or group tools is not available. 131 00:06:18,780 --> 00:06:21,600 We are having a problem here because of the space. 132 00:06:21,600 --> 00:06:22,770 In these yum groups, 133 00:06:22,770 --> 00:06:25,050 if you want to install a yum group 134 00:06:25,050 --> 00:06:28,020 that has a space in the name, use double quotes. 135 00:06:28,020 --> 00:06:28,980 And there we go. 136 00:06:28,980 --> 00:06:30,486 And you can see that everything 137 00:06:30,486 --> 00:06:34,590 that is a part of this yum group is now installed. 138 00:06:34,590 --> 00:06:38,220 That just takes a minute and should not take too long. 139 00:06:38,220 --> 00:06:40,410 There is one more thing that I want to show you 140 00:06:40,410 --> 00:06:42,150 and that is the repository. 141 00:06:42,150 --> 00:06:45,390 So repositories on a YUM based system 142 00:06:45,390 --> 00:06:50,310 are in /etc/yum.repos.d/. 143 00:06:50,310 --> 00:06:52,320 And in /etc/yum.repos.d/, 144 00:06:52,320 --> 00:06:55,170 we see the repositories. 145 00:06:55,170 --> 00:06:56,694 So I'm on CentOS. 146 00:06:56,694 --> 00:07:00,660 And the CentOS repository is defined in centos.repo. 147 00:07:00,660 --> 00:07:02,580 And here we can see an exact reference 148 00:07:02,580 --> 00:07:05,310 to the repositories which are online 149 00:07:05,310 --> 00:07:08,280 that are going to be used by this CentOS system. 150 00:07:08,280 --> 00:07:10,050 I think this is enough about YUM, 151 00:07:10,050 --> 00:07:11,850 should be enough to get you started. 152 00:07:11,850 --> 00:07:13,473 Let's go check out APT.