Hosting or Servers Logo
Top 15 DNF Commands for Your Linux Server
Linux on Monitor

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

DNF Version Command in Terminal

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

DNF Help Command in terminal

Image of First part of the DNF help pages

To check to see if any of the packages on your server need updating use this command.

dnf check-update

DNF Check Update With Available Packages

To update/ upgrade all the packages on your server, use this command.

dnf upgrade

Picture of terminal with command dnf upgrade showing

To see all the packages installed on your server use this command.

dnf list installed

DNF List Installed Command in terminal

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

DNF Search Command in terminal

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

DNF Install wget in terminal

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

DNF Clean All Command in terminal

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

DNF reinstall command in terminal

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 command in terminal

dnf repolist only shows enabled repositories. If you use the following command, you will also be able to view disabled repositories.

dnf repolist all

You Are Leaving Us

This link is being provided as a convenience and for informational purposes only it is not an endorsement or an approval of any of the products, services or opinions of the corporation or organization or individual. bears no responsibility for the accuracy, legality or content of the external site or for that of subsequent links.