DNF, a.k.a. “dandified yum,” is the default package manager for RHEL-based distributions like Fedora and AlmaLinux to help you manage your system packages by giving you functionalities like searching, installing, updating, removing, etc. packages from your Linux system.
Tutorial Details
Description | Dandified YUM |
Difficulty Level | Low |
Root or Sudo Privileges | Yes |
OS Compatibility | RHEL, Fedora, CentOS, AlmaLinux, etc. |
Prerequisites | DNF |
Internet Required | Yes |
Update the Package Database
Update your system package database with the latest package release information.
$ dnf check-update
Upgrade Packages
Upgrade the installed packages to the latest release information available in your local database:
$ sudo dnf upgrade
Searching Packages
Search for packages available for your system repository by using the following command:
$ dnf search [PACKAGE-NAME]
Package Information
Execute the following command to fetch the descriptive package information, like version, release, size, source, repository, URL, license, and description.
$ dnf info [PACKAGE-NAME]
Install Packages
Install a package by specifying its name in the “dnf install
” command.
$ sudo dnf install [PACKAGE-NAME]
Multiple packages can be installed by specifying each one of them with a space.
$ sudo dnf install [PACKAGE-ONE] [PACKAGE-TWO]
If the package is not available in the repository, download the rpm file of that package and specify the full path to the “dnf install
” command as shown.
$ sudo dnf install /path/to/file.rpm
To hide the package information list, use the “-q
” flag as shown.
$ sudo dnf install [PACKAGE-NAME] -q
To get the extra information along with the current, specify the “-v
” flag as shown.
$ sudo dnf install [PACKAGE-NAME] -v
Reinstall Packages
Packages might break, or configuration files might be corrupt. To revert back to the original state of the packages, use the following command:
$ sudo dnf reinstall [PACKAGE-NAME]
Remove Packages
If the package was accidentally installed or has become unnecessary, then remove it using the following command:
$ sudo dnf remove [PACKAGE-NAME]
Multiple packages can be removed by specifying each one of them with a space.
$ sudo dnf remove [PACKAGE-ONE] [PACKAGE-TWO]
Remove Unnecessary Package
While installing any package, it requires dependencies that are installed along with it; however, we remove the package but forget to remove dependencies, which can be done by the following command:
$ sudo dnf autoremove
Download the Package RPM File
If you do not have internet access on your system, go to your neighbor and ask for their system to download the rpm file for your package using the following command:
$ sudo dnf download [PACKAGE-NAME]
List of Installed Packages
Get the complete list of installed packages on your system by using the following command:
$ dnf list --installed
Find Package
Get the name of the package to which the specified file or feature belongs.
$ sudo dnf provides /etc/hosts
View Enabled Repository Information
Check the complete list of enabled repository names on your system.
$ dnf repolist
To get comprehensive information, use the following command:
$ dnf repoinfo
View Disabled Repository Information
Execute the following command to get a complete list of enabled and disabled repositories.
$ dnf repolist all
Adding Repository
Add a custom repository to install the packages it provides by specifying the repository address as shown below.
$ dnf config-manager --add-repo http://www.example.com/example.repo
Enable/Disable Repository
Enable a disabled repository by specifying its name using the following command.
$ dnf config-manager --set-enabled [REPOSITORY-NAME]
Disable an enabled repository by specifying its name using the following command.
$ dnf config-manager --set-disabled [REPOSITORY-NAME]
View Transaction History
Get the complete list of all actions performed by the DNF command to easily undo, redo, or roll back to different actions.
$ dnf history
Use the ID from the above command output to get descriptive information about the actions done by that operation.
$ dnf history info [ID]
Undo the changes made by that operation by using the ID as shown.
$ dnf history undo [ID]
Accidentally undo the operation; okay, now redo it using the same ID as shown below.
$ dnf history redo [ID]
List All Group Packages
Execute the following command to get all the packages related to each other that are grouped under a single umbrella, like Apache and PHP, grouped under the Server group.
$ dnf grouplist
Install Group Packages
Install all the packages under the same umbrella of group like Server group will install the Apache and PHP as shown.
$ sudo dnf groupinstall "Server"
Update Group Packages
Grouped packages can be easily updated to their latest release using the group name as shown.
$ sudo dnf groupupdate "Server"
Remove Group Packages
Remove all the packages installed by the group using the following command.
$ sudo dnf groupremove "Server"
Clear Cached Data
Remove the old cached data from the “/var/cache/dnf
” directory by using the following command.
$ dnf clean all
Downgrade Packages
First, get a list of all available versions of your package that you need to downgrade.
$ dnf --showduplicates list httpd
If you want to step down one version, then execute the following command without specifying the version.
$ sudo dnf downgrade httpd
However, you can directly jump to specifying the version by specifying the version information as shown.
$ sudo dnf install httpd-2.4.53
Excluding Packages from Transactions
Avoid upgrading packages with a system update by specifying the package name as shown.
$ sudo dnf upgrade --exclude=httpd
You can also add the package name to the “/etc/dnf/dnf.conf
” file to exclude it from being upgraded in the future.
exclude=httpd
Plugins
Install the officially supported Core DNF plugins and also third-party Extra DNF plugins to extend the DNF core functionalities using the following command.
$ sudo dnf install dnf-plugins-core-PLUGIN_NAME
Interactive Shell
Run the DNF interactive shell by using the following command:
$ dnf shell
That’s all for now. If you have any questions, do let us know in the comment section.
Join The Conversation
Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.