Linux Crash Course - The dnf Command

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello again everyone and welcome back to my linux essentials series which is actually now the longest running tutorial series in the entire history of this channel which is awesome and you know what since you guys love this series so much i'm going to keep it going for a while longer in fact i have quite a few episodes planned that i can't wait for you guys to see but anyway i'm kind of getting ahead of myself here in today's episode we're going to check out the dnf command and what is dnf you might ask well dnf is a package manager similar to apt and many other package managers out there but dnf is a popular package manager that can be found in all kinds of distributions such as fedora centos red hat rocky alma linux and others so i think it goes without saying that the dnf command is very important to learn and in this video i'm going to show you the basics but before i get into that i want to take a moment to mention the sponsor for today's video lenode the node is a linux focus cloud server provider and using their platform you could actually set up your very own cloud linux server in minutes you could use lynnote's platform to set up your own blog perhaps a nexcloud server a minecraft server but if you're not feeling particularly creative today then you can actually use their platform to spin up a linux instance that you can use while going through the tutorials in this series in fact they have all kinds of distributions available so if it's covered on learn linux tv then you could probably find it on lenode and best of all cloud servers on linux platform are very inexpensive you can get started with a linux instance for just five dollars a month but it's even more affordable because if you use the url that's on the screen right now then you'll be able to set up your brand new lenod account with 100 in credit and you can fit quite a few linux servers within that credit the credit is actually good for 60 days and i highly recommend you check out leno's platform because they are awesome so definitely check out lynnette's platform i highly recommend it and i really appreciate their continued sponsorship of learnlinux tv now with all that out of the way let's go ahead and check out the dnf command [Music] on my end right here i'm running fedora workstation that's the distribution that i've decided to use as the example in today's video but again if you use other distributions including but not limited to centos red hat alma rocky and others then of course the dnf examples that i'm going to be giving you will actually work on those distros as well now i mentioned that dnf is a package manager and if you're not already familiar with that concept a package manager is essentially a command line utility that fetches software from a remote repository and dnf is one of several package managers and other package managers include apt pacman zipper there's a number of them but what dnf does for us is it helps us actually fetch software and install it locally and if that software requires other packages or other pieces of software then it's actually going to install those requirements as well now let's see an example on my end let's just say that i don't know i want to run h-top h-top is one of my favorite system monitoring utilities out there and i even have an entire video about h-top but h-top is only going to work if i have it installed which clearly i don't because it's telling me right here command not found now to be fair you won't always know the exact name of the package that you want to install i just happen to know that the package i want to install is h-top is the same as the command so that is pretty easy for me to find out i will be showing you how to search for packages later but what i want to start out with is showing you how to install a package and since i clearly don't have htop installed on this particular computer well i think i'll start with that so let's go ahead and get started then first i'll prefix the command with sudo because as you probably already know any command that's going to make system-wide changes is going to need root permissions in sudo actually helps us elevate commands accordingly the command won't work if we actually don't use sudo but if you're logged in as root then you don't need to use sudo but i won't mention that going forward because you probably already knew that anyway but what i'm going to do is run sudo dnf because well that's what we're going over and what i want to do is install something so i'll use the keyword install and then i type the name of the package that i want to install which is going to be htop right above that is telling me that the command was not found so essentially what i'm doing is i'm making sure that it's installed so i'll press enter and then i'll type in my super secret password and now it's giving me a summary so from the output that we see right here we can see that clearly h-top is recognized as a package that i can install before it actually does what i asked it to do you know install the package it's giving me a little summary here to let me know what's going to happen if i were to continue it's going to take about 173 kilobytes of hard disk space which i have plenty of that so that's not going to be an issue but it's actually showing me down here that it's going to expand to kilobytes which again is fine now it's asking me if that's okay and it is and to answer yes i could type y now if i wanted to abort i could actually type n for no but if i actually type nothing and press enter then n is the default because that's capitalized and by simply typing nothing and pressing enter then i'm basically choosing the default which is no recalling that command dnf install h-top i'm going to this time let it proceed so i'll answer with y i'll press enter and it's going to download h top which it's already done and i couldn't even finish my sentence before h top is fully installed it's not that big of a utility didn't take any time at all to download so now what i should be able to do is type h-top and sure enough it's working i have h-top on my system as you can see right here and even though i'm using a desktop version of fedora it doesn't really matter if you have a desktop or a graphical user interface because one of the things i love most about h-top is that it runs well without a graphical user interface which makes it especially useful on servers now what i'm going to do is actually quit out of h top you get the idea h top wasn't installed and i was able to use the dnf command this one right here to get that installed on the system now i showed you guys an example of installing a package with dnf i installed h-top and like i mentioned i already knew the name of that package so it was pretty much a no-brainer i just ran sudo dnf install and then the name of the package which in our case was h-top but what if i have no idea what the name of the package is i could guess and i might be right and i've been right several times i've actually guessed before and i was right on the money but that's not really a great way to handle this now if the packages are named the same here on fedora as they are on debian and ubuntu which is not the case but if i was thinking that it might be the same name what i could try to do is run sudo dnf install and i'll type apache 2 because that is the name of the package on distributions that are based on debian but that's not going to work there's no such package so if i'm coming to fedora from ubuntu for example i might be pretty confused so what i'm going to do is give you an example of dnf search we won't need to prefix it with sudo this time around because we're not actually making changes we're just searching and what i want to do is search for apache that is what i want to install and how i thought the package was named didn't actually work out so let's see if we could find the actual name of the package now we get quite a few results here because the dns search command what that's going to do is actually show us the results of every package in the repositories that include the search term so as you can see here for example this package includes the word apache right in the description but this is not what we want if i scroll up and i do know the name of the package so i know what i'm looking for so this should be pretty quick the name of the package is right here httpd now we can ignore this part right here dot x86 underscore 64. that's the architecture of the package right there but we only need to focus on what's in front of the period which is going to be this right here so now that i know the name of the package what i'm going to do is run sudo dnf and then install and that package name httpd just like that and i actually installed it off camera when i was playing around so it's already installed in my case but we could just pretend like i didn't know the name of the package and i searched for it i found the name of the package and then i installed it if nothing else the takeaway right here in this part of the video is you could use dnf search and then some sort of keyword to find out what the packages are in the repository that meet that criteria if nothing else you can find the name of the package that you might want to install and dnf search will help you do that so what i'm going to do right now is give you guys additional examples of the dnf command because simply installing packages that's not all it can do it could do more for us than just that so let's see some additional examples and i'm going to go over these in well basically no particular order but the next one that i want to show you is going to be dnf list installed and it looks like that and what this command is going to do well you can probably guess what it does based on what i've just typed is going to give us a list of all the packages that have been installed so i'll press enter and as you can see it gave me a list of every package that is installed on the system now i didn't install all of these myself these are mostly just packages that actually came with fedora and that's how distributions of linux work you have packages or software that's pre-installed that's very common and packages within a linux system are going to be split into smaller sub packages or you know dependency packages libraries if you will so it's actually quite common to have a large number of packages that are installed along with the distribution and i was able to find that out by typing dnf list installed notice that i didn't use sudo this time the thing is with this command i'm not actually making changes to the distribution or the system in general all i'm doing is just reading information i want to know what's installed on the server and again since i'm not making changes i didn't have to use sudo for this i was able to run dnf list installed and it worked just fine in addition to that what we could do is type dnf list and then recent and what this is going to do for us is actually list all of the packages that have been recently updated in the repositories a repository is actually where a linux distribution gets its software from so even debian systems ubuntu systems basically just about every distribution they all utilize the concept of a repository which is where software comes from so when i run the dnf command and i install something like htop it's pulling it from the repository and every now and then packages or software within a repository are updated maybe there's security updates feature updates something like that so these packages are regularly updated and by running this command dnf list recent i could find out which packages in the repositories that the system is subscribed to have been recently updated that's pretty cool now for the next example what i want to do is install actually two different packages so again i'm going to use sudo i will be making changes to the system this time so of course i'll need to have access or privileges to do that and then i'll run dnf and then the keyword install and one of the packages that i want to install is called alacrity alacrity is a terminal emulator and it's actually one of the ones that i've covered in a recent video where i go through several different terminal emulators in one video i'll leave a card for that right about here but anyway alacrity is a graphical terminal emulator something that you might install on a linux desktop distribution but what i also want to do is i want to install ulauncher as well so i just press space and then the name of the second package which i think is a lot better than executing two different dnf commands i mean if i already know what i want to install i should be able to install more than one package all at the same time and that's actually the case as you can see right here with this command what i'm attempting to do at least is install alacrity and u-launcher i put a space in between those two package names and if this works then well dnf should actually get them both installed now i'm using fedora which you know obviously has a graphical desktop environment so if you are running on a server for example then these two packages right here are probably not a good idea to install these are just packages that i'm going to use as an example in my case but i'm going to go ahead and press enter but you know what before i do that since i'm on a graphical desktop environment i'm going to show you that these packages are not available right now so if i go to show applications i don't see alacrity here do you and also i don't see u-launcher either so i'm just making sure that these packages aren't already installed and they're not so let's go ahead and complete this command and get these packages installed so i'll press enter now this time around some additional dependencies are going to be installed as well so up here it shows the two packages that i've requested alacrity and u launcher but in order to satisfy the dependencies it's going to need to install these packages as well because without these dependencies then these packages can't actually function each one is going to have their own dependencies and the dependencies for each are going to be mixed in here together but this is very common dependencies that support a package or a piece of software that you want to run dnf is going to take care of that for us and make sure that everything the application needs is going to be installed on the system which is awesome we used to handle dependencies ourselves manually back in the day so trust me you should be very happy that that's not something that you have to do nowadays anyway i'll press y and then enter let's get these installed and there you go i have successfully installed alacrity and ulauncher but you know what let's just make sure that these packages were in fact installed so again i'm just going to go to activities i'll go down here to show applications and check it out we have alacrity right here which doesn't really look like much yet this is one of those things that you'll need to configure to make it look good but it's installed at least that's pretty cool back in applications let's look for u-launcher so we actually have more than one page now so here it is so we have both of those installed i also have a video on ulanger as well if you want to check that out it's a very convenient way to launch applications and i think you'll like it anyway we've seen several examples of installing a package but what about removing a package well let's go ahead and see an example of that right now so again we'll type sudo dnf and instead of the keyword install what we want to do is remove so i'll type remove and then the name of the package that i want to remove which i'll just use h top as an example i guess that was the first one that we've installed so i'll just use that one and i'll press enter and it's telling me right here that this is going to result in the removal of h top which is exactly what i wanted to do so i'll type y and then enter and that's going to remove h-top from the system so now as you can see i'm not able to run h-top it's no longer installed so that makes sense now let's see in another example of removing something but specifically i'll remove alacrity as well as you launcher and this will show you guys that you can actually list multiple packages to remove in one command similar to how you can install several things with one command so i'll press enter and as you can see here it's going to remove alacrity a new launcher and it's also going to remove these dependencies as well because those dependencies were installed to support these packages but now that i'm removing them we don't need those anymore and this is going to result in the removal of 10 different packages so i'll type y and then i'll press enter and it's already done it's erased all of those packages as you can see so if i go to activities and then i check out the application list well alacrity is missing i don't have the two pages u-launcher is clearly gone so it looks like the command was indeed successful but how do you handle a situation where you have a package on the system and a new version of that package has come out now on my end i actually have a pretty decent example here because firefox has been recently updated so what i could do is run sudo dnf and then upgrade and then after that i type the name of the package that i want to upgrade in my case that's going to be firefox and this is going to update just that package now if there's also updated dependencies as well then this command is going to result in the installation of those in addition but this is not going to be a system-wide upgrade though it's just going to upgrade firefox and the things that it requires so as you can see right here this is going to upgrade six different packages so i'll type y and then enter and we'll get the latest firefox package installed right here on this particular installation and it's hard to believe that we're all the way up to firefox version 100 yes 100. that's not a typo in the name of the package firefox is actually at version 100. where is the time gone anyway you just saw an example when it comes to upgrading a specific package and in this case like you've just seen i was able to upgrade firefox to the latest version but what if i want to do a complete distribution upgrade meaning i want to update everything and this is a very very very very very important thing to get in the habit of because on a linux system or any operating system for that matter it's really important that you have the latest packages because those packages will often include security enhancements as well and if you don't do a good job when it comes to installing the updates for your system you're actually increasing the overall risk so i recommend that you run this every now and then sudo dnf upgrade and since i didn't give it a specific package name i'm basically telling it to upgrade everything so i'll press enter and there's quite a few updates here 676 packages to be exact in fact this is a test installation that i've never upgraded ever so it makes sense why there's so many packages to be updated on your end if it gets to this point then that must mean that you haven't upgraded in a very long time hopefully that doesn't happen again you definitely want to stay on top of updates but what i'll do is type y and then enter all right so actually the process is complete all the packages have been updated on this system and what's actually interesting is that it appears that the wallpaper has changed as well and that's actually a really cool wallpaper i'm actually using a development version of fedora right now because i'm checking out a new fedora release so it makes sense that the wallpaper has changed because while a distribution is in development then anything could change but anyway you just saw an example of where i went and updated everything on the system with dnf upgrade which is exactly how you do that now i mentioned that updates are very important and they should make sure that your linux installations are kept up to date but i understand that life can get in the way and you might not remember to update now i could tell you to set a timer or maybe an alarm or some sort of like calendar alert or something like that but i generally find that that's not really all that effective thankfully with dnf you can actually install the automatic package the dnf automatic package and what that does is it helps you automate the process of keeping your installation up to date so let's go ahead and see an example of that right now what i'm going to do is run sudo dnf and then what i want to do is install and what i want to install is dnf hyphen automatic just like that and this is one step in a two-step process we first need to get the package installed and then we can configure the package so i'll press enter we'll go ahead and confirm that we do indeed want to get this installed so i typed y and then i pressed enter and it's already done so what we could do right now is edit a configuration file which is actually something that sometimes comes along for the ride when we install a new package on any distribution configuration files are very common because it tells the system how to well configure the package in our case we'll need to use sudo and that's because we're going to be making a system wide configuration change and i'm going to use nano a command line text editor to edit the configuration file for dnf automatic i have an entire video that goes over nano if you want to check that out but for our purposes we just need a text editor it really doesn't matter which one we use i just went along with nano because it's easier to explain in a video but anyway the file that we want to edit is going to be slash etsy dnf automatic dot com so i'll press enter and now we have the default config file for the dnf automatic package what we could do is go through this configuration file and make some changes if we need to as far as the individual details about how things are updated for example we have upgrade type which is set to default and as we can see right here the default option is going to give us all available upgrades now an alternative is the security option which is listed right here in this comment so we could actually change this to upgrade type equals security and if you're maintaining a server then this is probably the best setting for this right here because default like it says will update everything which means if the update includes a feature update but nothing that benefits security then it's still going to update it but if you set it to security specifically then the only packages that will be upgraded are the ones that offer security updates which might be better when it comes to company workstations and servers where change isn't always a great idea all the time but you definitely want to stay on top of the security updates and these options are pretty self-explanatory so i'll leave it up to you to go through this file and make some changes if you'd like to do so but what i'm going to do is save the changes right now which in the case of nano is ctrl o and then enter and then ctrl x to exit out and now we're back to the command line now before i close out the video there's a few more examples that i'd like to show you and for the first example what i'm going to do is actually install h-top again because i'm going to use it for the example that i'm going to show you so just like before i'll run sudo dnf install then h-top let's get that back on the system and that was pretty quick so for this example let's assume that you're having a very strange problem with a package that you've installed maybe it's just acting erratic or i don't know you're getting errors or something like that something you might want to consider doing is reinstalling the package now to be fair that's kind of what i've just done we installed h top earlier in the video i removed it and now i'm installing it again so you could argue that i've already reinstalled it well i have but you don't have to do it that way yes that does work but there's actually a reinstall command with dnf that'll take care of that for you so if you run sudo dnf and then you run reinstall and then you give it the name of the package that'll actually take you through that entire process so i'll press enter i'll answer y and it reinstalled the package for us it literally says reinstalled right there so if you ever run into a very strange problem and you want to try to reinstall a package that's actually a valid troubleshooting tactic now you know that you could do that with dnf now earlier in the video when i showed you the process of removing a package dnf also removed the dependencies as well but in case you have any dependencies that are hanging around that weren't removed there's a special command to take care of those as well so we can run sudo dnf and then auto remove just like that and what this should do is look for any packages that were installed as a dependency of another package that's no longer present but in a situation where the dependencies themselves have not been removed then this should go through the system find some dependencies that it can remove safely remove and take care of that for us so i'll press enter and check this out we actually have a few dependencies right here that were installed as a dependency of something else that's no longer present and that's good so you get to see an example of that so i'll answer why so dnf auto remove is something that you might want to consider running every now and then to help clean your system and with that that's all the examples of course there's other things that you could do with dnf those aren't the only options that exist but those are the basics which is the whole point of this series i've taught you the basics of dnf and with what i've shown you in this video you should have everything you need to make full use of the dnf command [Music] all right so there you go hopefully by now you understand the basics of the dnf command that's what we went over in today's video and dnf itself is a great package manager it's one of my favorites and if you like the dnf command in general then you're in good company if you use other distributions such as centos alma linux rocky linux among others because like i mentioned in the intro is definitely a popular package manager now if you found this video helpful please consider clicking that like button to let youtube know that other people might benefit from this content as well and also be sure to subscribe to learn linux tv for the latest in linux goodness including a bunch more episodes in this very series that i'm in the process of filming right now as always thank you so much for checking out this video and have a great day [Music] you
Info
Channel: Learn Linux TV
Views: 37,986
Rating: undefined out of 5
Keywords: Linux, gnu/linux, LearnLinuxTV, Learn Linux TV, LearnLinux.TV, Learn Linux, Linux Training, dnf, fedora, red hat, rhel, centos, alma linux, almalinux, rocky linux, rockylinux, dnf command, dnf tutorial, linux tutorial 2022, linux tutorial, linux commands, linux tutorial for beginners, linux command line tutorial, open source, command line, linux essentials, linux for beginners, linux terminal, operating system, how to, linux basic commands, linux server, linux operating system
Id: mL1hMBYP1bQ
Channel Id: undefined
Length: 28min 0sec (1680 seconds)
Published: Fri May 20 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.