yum & dnf Explained for Beginners!
When I was a beginner in Linux and I wanted to install any software, the online instructions I found would ask me to type something like this on my Fedora’s or CentO’s terminal
sudo yum install <software name>
or something like this
sudo dnf install <software name>
So I used to wonder what are these yum and dnf commands. In this article, I am trying to explain the need for these commands and what they do internally to install software and how they do it.
What is yum? YUM stands for YellowDog Updater Modified. It is a package manager that is used for managing the installation, updating, and removal of software packages in a RedHat based Linux system.
What is dnf? DNF stands for DaNdiFied(dandified) yum. It is the updated version of yum used for the same purpose of managing the installation,updating and removal of software packages in a RedHat based Linux system
That’s the short version of the answer, but don’t worry if you don’t understand it completely as this article is all about breaking down the above answer into parts and learning it in detail!
Let’s take this short answer and highlight the important terms that we need to understand.
It is a package manager that is used for managing the installation, updating and removal of software packages in a RedHat Based Linux System.
If you look at the above 2 lines from a beginner’s perspective a lot of questions come into mind. Some of these are
- What are these software packages?
- What is a package manager?
- What are the functions of a package manager?
- Why only RedHat based system?
- What are other alternatives for yum and dnf that I can use on my RedHat based system?
Let’s try to learn the answer to all these questions in detail in this article.
I have already written another article explaining all about packages and package managers in detail that you can find in the link below.
In that article, I have explained
- What are packages in a Linux system
- Content of packages
- Need for package managers
- Functions of package managers and
- the architecture of packages managers
If you haven’t already, please go ahead and read that one before continuing this article as that article should clear up most of the confusion that is common with beginners who would like to learn more about “yum” and ¨dnf¨ commands.
Alright, I guess by now, you have read that article and you are more familiar with the role of package managers like “yum” and ¨dnf¨ in our RedHat based Linux systems.
Let’s next look at the updated features that come with dnf that doesn’t come with yum
DNF vs YUM
As we have seen earlier, DNF is the updated replacement for YUM. The main problems with yum included the following
- Poor performance (since its built entirely on python )
- Too much memory consumption
- Poor documentation to build on top of
Due to these inefficiencies, RHEL developers chose to replace yum using dnf which uses a very good library named libsolv (developed and maintained by SUSE) to resolve dependencies. Since this library was built using C, C++ and python, it is efficient at performance and memory consumption and as a bonus, it has excellent documentation so that you can build on top of it easily!
If you are working on a RedHat based system that doesn’t use dnf but uses yum, just type in the command below to install dnf.
sudo yum install dnf
What does “RedHat based system” mean?
There are 2 types of Linux distros
- Original distributions
- Derived distributions
Making a Linux distro from zero involves a lot of work to put all the packages and the Linux kernel together into a single “distributable” Operating system.
Original distributions are those that are made this way from zero. In other words, these original ones take the kernel, GNU utilities, application software, etc. and combine them into an installable operating system and distribute them to the end-users usually over the internet. Popular examples of original distros include Debian, RedHat, Slackware, etc.
Derived distros are ones that take one of these original distributions, make some changes to it, so that its more suitable for a specific purpose and then distribute them as an installable operating system.
RedHat is the original distro here that used “yum”and “dnf” and all the distros derived from it also use the same package management system as their defaults. Some examples of RedHat derived distros include the Fedora, Oracle Linux and CentOS.
Will “dnf” only work on RedHat based systems?
No, you can use the “dnf” package manager on other systems too. But like I explained in this article dnf can only work with packages that follow the .rpm format. So the packages you that we are trying to install or remove or update must be in the .rpm format!
For example, you can’t open an excel “.csv” document using Microsoft word and expect it to work just fine. Similarly, DNF can only work with .rpm files!
You can still use def on Debian based distros or other Linux distros using tools like “alien” which converts between .deb and .rpm package formats, but the hassle to make everything work is not worth the effort, as conversions will bring their own set of problems in some circumstances.
So my advice is to stick to the default package managers that come with the Distros and learn their commands instead of trying to fit a square peg into a round hole!
5 Must know DNF commands for Beginners
Before I conclude this article, let me give you a list of 5 DNF commands which I think every beginner DNF user must know.
In place of <software name> just substitute your favourite software to see the results for example
sudo dnf install firefox
Make sure you prepend all these commands with sudo as they need administrative privileges.
|dnf install <software name>||acquires the software from the repo and installs it on your system|
|dnf remove <software name>||uninstalls the software from your system and|
|dnf upgrade||upgrades all the packages installed in your system to their latest available version in the repo.|
|dnf help <command>||if you don’t know what a specific dnf command does, you can use the help command to get more information.|
for example: dnf help upgrade will show you the exact action done by that command along with various options it accepts. It is useful to jog your memory!
|dnf search <string>||if you only remember part of the software name then you can use this command to get the names of software matching the provided string.|
for example: dnf search firefo will list all of the Firefox packages!
Memorise this list if possible, so that next time you can make “the magic spells”or “commands to install software” yourself without googling it when you wish to install software!
5 fun to try DNF commands
Let’s also see 5 fun-to-try DNF commands! Try these on your RedHat based machine to learn and explore DNF!
|dnf deplist <package name>||Will show you the complete list of dependencies a given software package has.|
Just try out the example of Firefox and see the huge list of dependencies Firefox needs to work on your machine!
|dnf history <package name>||shows the recent history of work done by dnf on the specified package.|
|dnf shell||gives an interactive prompt to enter dnf commands. Once you enter the prompt, you can basically type commands while excluding the sudo dnf part and just type in the commands!|
> history <package name>
<shows the history>
> deplist <package name>
<shows the dependency list>
it is useful if you wish to use dnf a bunch of times in one go!
you can type exit to leave the prompt.
|dnf info <package name>||gives information about the package installed in your system and latest version available in the repo so that you can choose whether to upgrade it or not|
|dnf clean all||cleans all the temporary files (metadata, cache, cached packages, etc)|
And with that, I will conclude this article!
I hope you guys enjoyed this article and learned something useful.
If you liked the post, feel free to share this post with your friends and colleagues!