1 00:00:07,320 --> 00:00:09,030 - So let's talk about apt. 2 00:00:09,030 --> 00:00:12,810 Apt is the Ubuntu equivalent to yum and dnf. 3 00:00:12,810 --> 00:00:15,180 It's the Ubuntu software manager. 4 00:00:15,180 --> 00:00:17,880 Apt is a newer replacement of older utilities 5 00:00:17,880 --> 00:00:20,100 like apt-cache and apt-get. 6 00:00:20,100 --> 00:00:24,630 In older versions of Ubuntu, you had apt hyphen whatever. 7 00:00:24,630 --> 00:00:25,980 Now there's a main interface, 8 00:00:25,980 --> 00:00:28,800 and this main interface is just apt 9 00:00:28,800 --> 00:00:32,070 followed by the functionality that you want to perform. 10 00:00:32,070 --> 00:00:35,760 Now like yum, apt was developed to work with packages 11 00:00:35,760 --> 00:00:37,890 in an intuitive way. 12 00:00:37,890 --> 00:00:42,210 So apt repositories are defined in /etc/apt/sources.list, 13 00:00:42,210 --> 00:00:45,750 and there's also an option to work with drop-in files 14 00:00:45,750 --> 00:00:49,320 that you would store in /etc/apt/sources.d. 15 00:00:49,320 --> 00:00:51,030 Now how do we work with apt? 16 00:00:51,030 --> 00:00:52,380 Well, first you need to make sure 17 00:00:52,380 --> 00:00:54,480 that the local list of packages is updated 18 00:00:54,480 --> 00:00:57,060 to the most recent version of packages 19 00:00:57,060 --> 00:00:59,790 by using the apt update command. 20 00:00:59,790 --> 00:01:02,883 And you can use apt search to search for packages. 21 00:01:03,960 --> 00:01:07,110 The apt install command is what you are going to use next, 22 00:01:07,110 --> 00:01:09,420 and that'll install the package. 23 00:01:09,420 --> 00:01:12,180 Now you will notice if you install packages with apt, 24 00:01:12,180 --> 00:01:14,070 if a package contains a service, 25 00:01:14,070 --> 00:01:16,950 then it will be started and enabled automatically. 26 00:01:16,950 --> 00:01:18,030 So you don't have to deal 27 00:01:18,030 --> 00:01:21,123 with the systemctl command separately. 28 00:01:22,320 --> 00:01:25,170 You can use apt upgrade to upgrade packages 29 00:01:25,170 --> 00:01:29,070 or even apt dist-upgrade, that's dist hyphen upgrade, 30 00:01:29,070 --> 00:01:32,103 to upgrade your entire distribution to a new version. 31 00:01:33,120 --> 00:01:35,880 Sometimes packages are installed as dependencies 32 00:01:35,880 --> 00:01:37,290 but no longer required. 33 00:01:37,290 --> 00:01:38,640 Apt will tell you about it. 34 00:01:38,640 --> 00:01:42,060 And then you can use apt autoremove to remove them. 35 00:01:42,060 --> 00:01:45,513 And finally, if you are looking for a specific package, 36 00:01:45,513 --> 00:01:49,740 then you can use apt-cache search on a filename. 37 00:01:49,740 --> 00:01:53,610 That will show you packages that contain a specific file. 38 00:01:53,610 --> 00:01:56,760 It's kind of the equivalent to yum provides. 39 00:01:56,760 --> 00:01:57,903 Let me demonstrate. 40 00:02:00,660 --> 00:02:02,600 All right, so the first thing I'm going to do 41 00:02:02,600 --> 00:02:04,383 is sudo apt update. 42 00:02:05,224 --> 00:02:09,063 Sudo apt update, make sure that we update the package cache. 43 00:02:10,110 --> 00:02:12,990 In this procedure, it's contacting the repositories, 44 00:02:12,990 --> 00:02:15,720 and it is making sure that the most recent index files 45 00:02:15,720 --> 00:02:18,450 from the repositories are fetched, 46 00:02:18,450 --> 00:02:20,520 so that we can easily install packages, 47 00:02:20,520 --> 00:02:23,010 and we have all the information that we need 48 00:02:23,010 --> 00:02:24,513 available locally. 49 00:02:25,410 --> 00:02:26,970 You can see that apt update 50 00:02:26,970 --> 00:02:31,970 is automatically analyzing for me what is going on. 51 00:02:32,250 --> 00:02:34,500 And it even makes a suggestion, 52 00:02:34,500 --> 00:02:38,310 that is use apt list --upgradeable, 53 00:02:38,310 --> 00:02:42,000 because there are packages that seem to be upgradeable. 54 00:02:42,000 --> 00:02:45,480 So all of this is what I can upgrade. 55 00:02:45,480 --> 00:02:48,324 I'll tell you, I will do the upgrade in just a little bit. 56 00:02:48,324 --> 00:02:52,560 All right, let's go start and use sudo apt search 57 00:02:52,560 --> 00:02:57,060 to search for packages based on nmap, for instance. 58 00:02:57,060 --> 00:02:58,170 Now what do we see? 59 00:02:58,170 --> 00:03:01,380 We see too much information right here, honestly. 60 00:03:01,380 --> 00:03:03,810 I mean, let's pipe it through wc. 61 00:03:03,810 --> 00:03:05,520 I like wc, that's word count. 62 00:03:05,520 --> 00:03:10,500 101 lines, who is ever going to read 101 lines? 63 00:03:10,500 --> 00:03:14,400 Does it help to have a look only at the top of the output? 64 00:03:14,400 --> 00:03:17,280 And there we see that doesn't even help. 65 00:03:17,280 --> 00:03:20,790 I'm looking for my nmap package, but I can't find it. 66 00:03:20,790 --> 00:03:25,790 So let me do a sudo apt-cache search on nmap, 67 00:03:29,250 --> 00:03:31,290 which is going to search in the apt cache, 68 00:03:31,290 --> 00:03:34,833 and which is producing a list of packages 69 00:03:34,833 --> 00:03:38,310 that is a lot easier to work with. 70 00:03:38,310 --> 00:03:41,490 So I have the nmap package, and that is okay. 71 00:03:41,490 --> 00:03:44,553 Let's install it, sudo apt install nmap. 72 00:03:45,810 --> 00:03:48,090 And that'll install the nmap package for me, 73 00:03:48,090 --> 00:03:50,160 including all of the dependencies. 74 00:03:50,160 --> 00:03:51,480 You can see right here, 75 00:03:51,480 --> 00:03:53,580 following new packages will be installed. 76 00:03:53,580 --> 00:03:55,290 And of course I want to continue, 77 00:03:55,290 --> 00:03:57,740 because that is what I've been asking for, right? 78 00:03:58,920 --> 00:04:00,510 So there we go. 79 00:04:00,510 --> 00:04:03,780 Now one other thing that you might want to do frequently 80 00:04:03,780 --> 00:04:06,720 with apt is sudo apt upgrade. 81 00:04:06,720 --> 00:04:09,570 So sudo apt upgrade is upgrading packages. 82 00:04:09,570 --> 00:04:12,420 Only one megabyte, that is doable. 83 00:04:12,420 --> 00:04:13,500 So let's do it. 84 00:04:13,500 --> 00:04:16,680 And it'll upgrade these packages for me. 85 00:04:16,680 --> 00:04:20,850 Especially if you are not in the LTS version of Ubuntu, 86 00:04:20,850 --> 00:04:23,820 or in my case, I'm in the daily build version 87 00:04:23,820 --> 00:04:28,260 of the Ubuntu 22.04, then it is useful 88 00:04:28,260 --> 00:04:30,780 to do upgrades and do upgrades a lot, 89 00:04:30,780 --> 00:04:34,410 so that you have access to the latest and greatest software. 90 00:04:34,410 --> 00:04:35,520 Do keep in mind, though, 91 00:04:35,520 --> 00:04:38,310 that doesn't always match the security policy 92 00:04:38,310 --> 00:04:39,750 used by companies. 93 00:04:39,750 --> 00:04:42,570 Some companies need to verify the packages 94 00:04:42,570 --> 00:04:44,910 before any upgrades can be done. 95 00:04:44,910 --> 00:04:46,080 All right, and with that, 96 00:04:46,080 --> 00:04:47,913 I think we've seen enough about apt.