The Dandified Yum (DNF) command is the next-generation successor to the Yum (Yellowdog Update Manager) package manager on RPM-based Linux machines. It was originally introduced in Fedora version 18 in 2015 and has since been adopted in various other versions of Linux including Centos, Red Hat, and others. DNF aims to maintain command-line compatibility with YUM whilst also improving performance and memory usage.
This article will show you the top 10 most useful DNF commands for package management on your Linux server as well as how to install DNF on your server in the rare case it is not already installed.
Let’s check to see if DNF is installed and which version it is. Enter the following command.
dnf --version
If dnf is not found, then you need to install it using YUM. Enter the following command.
yum install dnf
Now we are all on the same page here are the top 10 DNF commands for your server.
If you are stuck or just need some assistance, then enter the dnf command for help.
dnf help
To check to see if any of the packages on your server need updating use this command.
dnf check-update
To update/ upgrade all the packages on your server, use this command.
dnf upgrade
To see all the packages installed on your server use this command.
dnf list installed
To search for a particular package, use the following command. We searched for postfix, just replace that with the name of the package you are looking for.
dnf search postfix
To install a package, use the following command. We used it to install wget, you should replace wget with the name of the package you wish to install.
dnf install wget
If you add -y at the end of a command, DNF will assume your answer to questions is yes and not prompt you for input.
dnf install wget -y
Now you know how to install a package we will show you how to remove one. Let's demonstrate by removing the wget package. It is recommended not to use the -y option when removing a package so you can check what unexpected packages may be removed at the same time.
dnf remove wget
During use DNF builds a cache of package and repository information to help speed up its operations. This can be cleaned using the following command.
dnf clean all
This command removes any stray dependencies left by packages during their removal or updates etc.
dnf autoremove
If your server has crashed or a file has become randomly corrupted, you may want to reinstall a package. Use the following command replacing wget with the package name of your choosing.
dnf reinstall wget
There are usually several repositories configured for DNF to read. To find out which ones are enabled on your server use the following command.
dnf repolist
dnf repolist only shows enabled repositories. If you use the following command, you will also be able to view disabled repositories.
dnf repolist all