VOOZH about

URL: https://www.tecmint.com/dnf-commands-for-fedora-rpm-package-management/

⇱ 27 'DNF' (Fork of Yum) Commands for RPM Package Management in Linux


Skip to content

DNF aka Dandified YUM is a next generation Package Manager for RPM based Distribution. It was first introduced in Fedora 18 and it has replaced YUM utility in recent release of Fedora 22.

πŸ‘ Linux DNF Command Examples

DNF aims at improving the bottlenecks of YUM viz., Performance, Memory Usages, Dependency Resolution, Speed and lots of other factors. DNF does Package Management using RPM, libsolv and hawkey library. Though it does not come per-installed in CentOS and RHEL 7 you can yum, dnf and use it alongside the yum.

You may like to read more about DNF here:

  1. Reasons Behind Replacing Yum with DNF

The latest stable release of DNF is 1.0 (at the time of writing of post) which was released on May 11, 2015. It (and all previous version of DNF) is mostly written in Python and is released under GPL v2 License.

Installation of DNF

DNF in not available in the default repository of RHEL/CentOS 7. However Fedora 22 ships with DNF implemented officially.

To install DNF on RHEL/CentOS systems, you need to first install and enable epel-release repository.

# yum install epel-release
OR
# yum install epel-release -y

Though it is not ethical to use β€˜-yβ€˜ with yum as it is recommended to see what is being installed in your system. However if this does not matter you much you may use β€˜-y’ with yum to install everything automatically without user’s intervention.

Next, install DNF package using yum command from epel-release repository.

# yum install dnf

After dnf installed successfully, it’s time to show you 27 practical usage of dnf commands with examples that will help you to manage packages in RPM based distribution easily and effectively.

1. Check DNF Version

Check the version of DNF installed on your System.

# dnf --version

πŸ‘ Check DNF Version

2. List Enabled DNF Repositories

The option β€˜repolistβ€˜ with dnf command, will display all enabled repositories under your system.

# dnf repolist

πŸ‘ Check All Enabled Repositories

3. List all Enabled and Disabled DNF Repositories

The option β€˜repolist allβ€˜ will print all the enabled/disabled repositories under your system.

# dnf repolist all

πŸ‘ List All Enabled/Disabled Repositories

4. List all Available and Installed Packages using DNF

The command β€œdnf list” will list all the available packages from all the repositories and installed packages on your Linux system.

# dnf list

πŸ‘ List All Packages using DNF

5. List all Installed Packages using DNF

While the β€œdnf list” command shows all the available/installed packages from all the repositories. However, you have the option to list only the installed packages using option β€œlist installed” as shown below.

# dnf list installed

πŸ‘ List All Installed Packages

6. List all Available Packages using DNF

Similarly, the β€œlist available” option, will list all the packages available to be installed from all the enabled repositories.

# dnf list available

πŸ‘ List Available Packages using DNF

7. Search for a Package using DNF

If incase, you’ve no idea about the package that you want install, in such situation you may use β€˜searchβ€˜ option with dnf command to search for the package that matches the word or string (say nano).

# dnf search nano

πŸ‘ Search Package by Word

8. See what Provides a file/sub-package?

The dnf option β€œprovides” find the name of the package that provides specific file/sub-package. For example, if you would like to find what provides β€˜/bin/bashβ€˜ on your system?

# dnf provides /bin/bash

πŸ‘ Find File Sub Package

9. Get Details of a Package using DNF

Let’s assume you want to know the information of a package before installing it on the system, you may use β€œinfo” switch to get a detailed information about a package (say nano) as below.

# dnf info nano

πŸ‘ Check Package Information with DNF

10. Install a Package with DNF

To install a package called nano, just run the below command it will automatically resolve and install all required dependencies for package nano.

# dnf install nano

πŸ‘ Install Package using DNF

11. Updating a Package using DNF

You may update only a specific package (say systemd) and leave everything on the system untouched.

# dnf update systemd

πŸ‘ Update a Specific Package

12. Check for System Updates using DNF

Check updates for all the system packages installed into the system simply as.

# dnf check-update

πŸ‘ Check For System Update

13. Update All System Packages using DNF

You may update the whole system including all the installed packages with following commands.

# dnf update
OR
# dnf upgrade

πŸ‘ Update System

14. Remove/Erase a Package using DNF

To remove or erase any unwanted package (say nano), you may use β€œremove” or β€œerase” switch with dnf command to remove it.

# dnf remove nano
OR
# dnf erase nano

πŸ‘ Remove Package in Linux

15. Remove Orphan Packages using DNF

Those packages that were installed to satisfy dependency may be useless if not being used by other applications. To remove those orphan packages execute the below command.

# dnf autoremove

πŸ‘ Remove Orphan Packages

16. Remove Cached Packages using DNF

A lot of time we encounter out-of-date headers and unfinished transactions which results into error while executing dnf. We may clean all the cached packages and headers containing remote package information simply by executing.

# dnf clean all

πŸ‘ Remove DNF Cache

17. Get Help on Specific DNF Command

You may get help of any specific dnf command (say clean) just by executing the below command.

# dnf help clean

πŸ‘ Get DNF Command Help

18. List all DNF Commands and Options

To list help on all available dnf commands and option simply type.

# dnf help

πŸ‘ Get Help on DNF Options

19. View History of DNF

You may call dnf history to look at the list of already executed dnf commands. This way you can be aware of what was installed/removed with time stamp.

# dnf history

πŸ‘ Check DNF History

20. List all Group Packages

The command β€œdnf grouplist” will print all available or installed packages, if nothing is mentioned, it will list all known groups.

# dnf grouplist

πŸ‘ List All Group Packages

21. Install a Group Package using DNF

To install a Group of packages bundled together as group package (say Educational Software) simply as.

# dnf groupinstall 'Educational Software'

πŸ‘ Install Group Packages

22. Update a Group Package

Let’s update a Group Package (say Educational Software) by executing the below command.

# dnf groupupdate 'Educational Software'

πŸ‘ Update Group Package

23. Remove a Group Package

We can remove the group Package (say Educational Software) as.

# dnf groupremove 'Educational Software'

πŸ‘ Remove Group Package

24. Install a Package from Specific Repository

DNF makes it possible to install any specific package (say phpmyadmin) from a repo (epel) as simply as,

# dnf --enablerepo=epel install phpmyadmin

πŸ‘ Install Package From Specific Repo

25. Synchronize Installed Packages to Stable Release

The command β€œdnf distro-sync” will provides necessary options to synchronize all installed packages to most recent stable version available from any enabled repository. If no package is selected, all installed packages are synchronized.

# dnf distro-sync

πŸ‘ Synchronize Packages to Stable Version

26. Reinstall a Package

The command β€œdnf reinstall nano” will reinstall an already installed package (say nano).

# dnf reinstall nano

πŸ‘ ReInstall Package

27. Downgrade a Package

The option β€œdowngrade” will downgrades the named package (say acpid) to lower version if possible.

# dnf downgrade acpid
Sample Output
Using metadata from Wed May 20 12:44:59 2015
No match for available package: acpid-2.0.19-5.el7.x86_64
Error: Nothing to do.

My observation: DNF does not downgraded the package as it is supposed to. It has also been reported as bug.

Conclusion

DNF is the upper state of the end of the art Package Manager YUM. It tends to do a lot of processing automatically which is not going to be praised by many experienced Linux System Administrator, as I believe. As a matter of example:

  1. --skip-broken is not recognized by DNF and there is no alternative.
  2. There is nothing like β€˜resolvedepβ€˜ command however you may run dnf provides.
  3. There is no β€˜deplistβ€˜ command to find package dependency.
  4. You exclude a repo, means the exclusion apply on all operations, unlike yum which excludes those repos only at the time of install and updates, etc.

Several Linux users are not happy the way Linux Ecosystem is moving. First Systemd removed init system v and now DNF will be replacing YUM sooner in Fedora 22 and later in RHEL and CentOS.

What do you think? are distributions and the whole Linux ecosystem is not valuing it’s users and moving against their will. Also it is often said in IT industry – β€œWhy fix, If not broken?”, and neither init System V is broken nor YUM.

That’s all for now. Please let me know your valuable thoughts in the comments below. Like and share us and help us get spread.

If this article helped, share it with someone on your team.
TecMint Weekly Newsletter
Get the Learn Linux 7 Days Crash Course free when you join 34,000+ Linux professionals reading every Thursday.
Check your email for a magic link to get started.
Something went wrong. Please try again.
β˜•
TecMint has been free for 14 years. Help keep it that way.
Google AI Overviews and tools like ChatGPT have cut into search traffic for independent tech sites like TecMint. Running this site costs over $2,000 every month for hosting, infrastructure, and paying authors to keep the content accurate and tested.

If this article helped you solve a problem, consider buying a coffee. It helps keep TecMint free, supports the authors, and keeps the project going.
β˜• Buy Me a Coffee
Avishek
A Passionate GNU/Linux Enthusiast and Software Developer with over a decade in the field of Linux and Open Source technologies.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

19 Comments

Leave a Reply
  1. Why do Tecmint authors prefix all the sample commands in their articles with a hash mark (#)? If entered as printed, the commands will never execute because # denotes a comment.

    Reply
    • @dragonmouth,

      In Linux, the "#" symbol specifically denotes the root user in the command-line interface.

      My apologies for the confusion earlier. You are right; in the context of Unix-like systems, including Linux, the β€œ#” symbol specifically denotes the root user in the command-line interface.

      In the terminal, the "#" symbol is the default prompt for the root user. When you log in as the root user or use the β€œsu” command to switch to the root user, the command prompt changes from the regular user prompt (usually ending with "$") to the root prompt (ending with "#").

      This indicates that you have superuser privileges and can perform administrative tasks without needing to use the β€œsudo” command.

      Reply
  2. I first installed epel-release.

    Then DNF.

    But at the very first step of dnf --version getting the below error :

    'Segmentation fault (core dumped).'
    

    I am using CentOS 7.4.

    Reply
  3. Can dnf list the files of a package without installing it?
    On debian, apt-file is able to do that:
    $ apt-file list iozone3
    iozone3: /usr/bin/fileop
    iozone3: /usr/bin/iozone
    …[skip]…

    Reply
  4. I agree with @Robert: I believe systemd will help unify and simplify Linux administration, improve security, and create opportunities for new features such as nspawn’s light-weight, system level process virtualization (maybe not a perfect description but check it out anyway).

    Reply
  5. Go, go, go, DoNut Fork!

    Reply
  6. not able to install f77
    after installing fedora 22 plz give me right instructions

    Reply
  7. Linux needs to move forward. Fedora and RHEL are updating these systems because they are holding Linux in the past.

    SystemD actually makes admin tasks easier and less likely to break with package updates. Settings set by Admins are in different location to settings delivered in packages. It also provides a lot of feed back in the service status output, including which config files are used. Also systemd does many things that traditional init did not, event driven, parallel starts and actually monitoring the services it manages instead of the sysV start it an hope.

    In short systemd is a change that was desperately needed to modernise and simplify Linux and simplify the administration of Linux. It is an system manager and not just an init system, which is why it is quite an all encompassing change.

    DNF I feel is the same. I have read there where fundamental problems in the resolving of dependencies in YUM and I know I have broken Linux with updates.

    I suggest take a little time to read up and try it out before dismissing the upgrades. I know I wasn’t so keen on systemd until I learned a little more about it

    Reply
    • could not agree more!

      Reply
  8. I also agree with you,
    As init and yum both are working good in older versions of Linux.
    In new dist. Linux they replace init with systemd and now in future yum will replace by dnf..

    Reply
    • Yeah! that’s my point.

      Reply
  9. Hi,
    Thanks a lot for nice article
    please change
    β€œNext, install DNS package using yum command from epel-release repository.”
    to
    β€œNext, install DNF package using yum command from epel-release repository.”

    Reply
    • Thanks for pointing out that typo..corrected in the article

      Reply
  10. I agree with you. DNF and Systemd are options to yum and SysV init, but Fedora and RHEL are simply doing a substitution despite the users complaint (mostly over Systemd because it is generating incompatibilities). Sad but true.

    As far as I saw in your article, dnf and yum are almost interchangeable.

    I think this attitude gone to hurt Linux badly :(.

    Pietro Pesci Feltri

    Reply
    • Yeah true! but think the difference in implementation.
      In earlier system
      # service apache2 stop

      Now
      # systemctl stop apache2

      In case of DNF/YUM, most of things are same, except better dependency resolution by dnf and deprecated yum.

      Reply
  11. please write article about yum vs dnf…
    Let us know the merits and demerits of yum and dnf…

    Reply
    • I have Already covered – Idea to replace yum with DNF, DNF Development,… which you may find in the link below.
      https://www.tecmint.com/dnf-next-generation-package-management-utility-for-linux/

      Practically there is nothing to compare between yum and dnf. Both serves the same purpose. In Fedora 22 yum is deprecated and if you fired yum as a habit, your command will be redirected to dnf automatically and you will get a warning that yum is deprecated. Most of the command implementation are same on either package manager, which you may confirm with the examples in the above DNF GUIDE.

      Reply

Got Something to Say? Join the Discussion... Cancel reply

Free Course
Get a free Linux course before you go.
Subscribe to TecMint Weekly and get the Learn Linux 7 Days Crash Course free. Read by 34,000+ Linux professionals every Thursday.
Check your email for a magic link to get started.