Since Fedora 22, DNF (Dandified Yum) has replaced Yum to become the default software package manager of the Fedora distribution. Considering the demonstration effect of Fedora, it is just a matter of time before DNF becomes fashionable on other RPM-based distributions.
Compared with Yum, DNF:
achieves faster dependency resolving speed with less memory usage,
provides specific and solid Python API documentation,
runs in both Python 2 and Python 3 environments, and
has similar synopsis and usage.
Besides working on all of the RPM-based distributions, DNF can also co-exist with its predecessor, Yum. So you can already pilot DNF on CentOS or other RPM-based distributions without concerns.
All of the instructions in this tutorial are geared to the needs of a sudo
user on a Vultr CentOS 7 server instance. You need to log in as a sudo
user to test the following commands. For instructions on how to create such a user, see this Vultr tutorial.
You need to setup the EPEL Yum repo before you can install DNF.
sudo yum install epel-release
sudo yum install dnf
Note:
On CentOS 6, you will get a "No package dnf available" notice after you have run the commands above, because the DNF program has not been added into the EPEL 6.x Yum repo. You would need to build DNF from source.
Synopsis of the dnf
command:
[sudo] dnf [options] <command> [<arguments>...]
Now, I will show you some examples of how to use DNF:
sudo dnf upgrade
or
sudo dnf update
Unlike in Yum, DNF's "update" sub command is deprecated, now it becomes the alias of "upgrade".
dnf list <package-name>
You can use wildcards to match more packages:
dnf list php*
dnf list --installed <package-name>
dnf repolist
sudo dnf install <package-name>
sudo dnf install <package1-name> <package2-name> <package3-name>
sudo dnf reinstall <package-name>
sudo dnf upgrade <package-name>
sudo dnf remove <package-name>
sudo dnf autoremove
sudo dnf clean all
You can consult the dnf
man page to learn more about dnf sub commands and usages:
dnf --help
or
dnf -h
or
man dnf