DNF was first made available in Fedora 18 & with Fedora 22, it had replaced Yum to become default package manager for handling the system package files. DNF or Dandified YUM is actually a fork of YUM package manager.

The problems like poor performance, high memory usage, slowness for dependency resolution etc, that have been associated with yum, DNF improves on them. In simple terms, it can be said to the future of YUM.

Recommended Read : Working with RPMs: Redhat Package Manager (with examples)

Also Read : Working with YUM command (with examples)

In this tutorial, we will discuss the DNF command with examples, so let’s start,


DNF command with examples


Package installation

To install in DNF, we use the ‘install’ option followed by package name,

$ sudo dnf install package


Package Removal

To remove a package, we can either use ‘remove’ or ‘erase’ option,

$ sudo dnf remove package

$ sudo dnf erase package


Package Update

To update only a single package on the system, execute the following command,

$ sudo dnf update package


Full system update

To check the available updates for all the system packages, we can run the following,

$ sudo dnf check-update


All system packages Upgrade

When all packages installed on the server are to be upgraded, we can use,

$ sudo dnf upgrade


List enabled repositories

To check all the repositories that are currently enabled on the system, we will use

$ sudo dnf repolist


List all repositories

To get the list of all the repos, whether they are enabled or disabled, use the following command,

$ sudo dnf repolist all


Enable repo for installation

To install a package from a particular repository, we need to enable the repo first. We can do this with the following command,

$ sudo dnf --enablerepo=repo-name install package


List all group packages

To get the list of all the group packages available for the system, run the following command

$ sudo dnf grouplist


Group packages Installation

It's similar to installing a single package but we replace the ‘install’ option with ‘groupinstall’,

$ sudo dnf groupinstall ‘group_name’


Group packages removal

To remove a complete group of packages from the system, run the following dnf command,

$ sudo groupremove ‘group_name’

We can also use ‘groupupdate’ for updating the group packages as well.


Re-install a package

If a package requires re-installation, use the following command,

$ sudo dnf reinstall package


Upgrade to a particular version

If required to upgrade to a particular version, we can use the following command,

$ sudo dnf upgrade-to package_version


List all available packages

To get list of all available packages from repositories, open terminal & run

$ sudo dnf list available


List installed packages

To get the list of all installed packages on the system, use the following command,

$ sudo dnf list installed


List all installed & available packages

To print the list of all installed & available packages, use the following command

$ sudo dnf list


Search packages

To look for a particular package from the repositories , execute

$ sudo dnf search package


Download-Only a package

To only download an available package (& not install it), execute the following command,

$ sudo dnf download package


Check package name to get a required functionality

To get the package name for command, we can use option ‘provides’ followed by command name or also we can use a file name in place of command name,

$ sudo dnf provides funtionality_name

$ sudo dnf provides /file_path

For example,

$ sudo dnf provides httpd

$ sudo dnf provides /etc/httpd/conf/httpd.conf


Check package information

To get all details about a package, use the following command,

$ sudo dnf info package


Check the DNF history

To get list of all DNF history i.e. all package installation/removal/updates etc. Run the following command,

$ sudo dnf history

You will than get list of all operations completed with DNF along with number. To get complete details about a particular DNF operation, run

$ sudo dnf history info 13


Synchronize all the packages to latest stable releases

To sync a package to the latest stable release,

$ sudo dnf distro -s sync package

To sync all the packages to latest stable release, use

$ sudo dnf distro-sync


List all options for DNF command

To get a list of all the available options that can be used with DNF, run

$ sudo dnf help


With this end our tutorial on DNF command with examples. Please do leave us any questions or queries you have regarding this article using the comment box below.

If you think we have helped you or just want to support us, please consider these :-

Connect to us: Facebook | Twitter | Google Plus

Donate us some of your hard earned money: [paypal-donation]

Linux TechLab is thankful for your continued support.