What is Fedora’s DNF package manager and how to use it?
What is DNF?
DNF or Dandified YUM is the package manager of Fedora and Fedora derivatives and is the successor of Yellow-dog Updater Modified or YUM package manager. It is used to manage packages, i.e. install, upgrade, update, reinstall, and uninstall them among other things. DNF has been the default package manager of Fedora since version 22 (2015) and it was first introduced in version 18 in 2013.
DNF vs RPM
RPM is also a package management system in Fedora and DNF works on top of it. Fedora’s documentation pushes users towards DNF instead of using RPM, as it is not capable of automatically finding and installing dependencies of a package, which means users will have to manually find and install them.
Today we will learn how to use the DNF package manager; i.e. You would learn how to install, search, uninstall, and do more things using it.
Structure of command
The basic structure of the command is
DNF [options] COMMAND
Basic and most frequent commands
Search packages
This command is used when you want to search Fedora repositories for a given package, after entering this command it will show all the available packages in the repository which match the search term, it searches within the name first, then searches for matches in name and summary. It is similar to how you search for packages in graphical stores.
To search for a package, you need to enter the “search” command along with the package that you want and it will show you all available packages matching that query:
dnf search [package name]
Installing packages
The “install” command will help you to install packages from the repositories. You can use this command to install one or multiple packages, to install multiple packages you just have to type the name of the packages with a space in between them. This command requires sudo privileges.
To install one package
sudo dnf install [[package name]]
To install multiple packages
sudo dnf install [[package 1]] [[package 2]] [[package 3]] ..... [[package n]]
Upgrading packages and system
Nobody likes old packages, so if you want to update your system along with its packages you can use the “upgrade” command. Sudo privileges are required.
sudo dnf upgrade
Upgrade a specific package
to upgrade a specific package you need to type
sudo dnf upgrade [[package name]]
Listing available updates
To check for available package updates without installing them you should enter:
dnf check-update
Removing packages
A package broke your computer or maybe you don’t need it anymore, in that case, you can use the “remove” command to uninstall applications from the system, this is equivalent to the “remove” command in Debian-based systems. This also needs sudo privileges to run.
sudo dnf remove [[package name]]
Removing multiple packages
To remove multiple packages you should enter the name of each package separated by a space.
sudo dnf remove [[package 1]] [[package 2]] [[package 3]] ..... [[package n]]
Removing unused dependencies
You uninstalled the package but it still has a lot of leftovers in your system in the form of dependencies, you don’t have to worry, just use the “autoremove” command to remove all the dependencies left behind in the system. You need to have “sudo” privileges for this command to work.
sudo dnf autoremove
Reinstalling packages
You accidentally broke a package (it happens ok!) or it just started acting up, you can easily reinstall it using the following command.
sudo dnf reinstall [[package name]]
Listing packages
To list all the available packages in the repository (for some reason if you just want to do that! you do you.) you could enter the following command
dnf list
Listing the packages you installed
The “dnf list” command will list all the available packages in the repository, but most of the time that is of no use to us; to list only the packages that you installed you could use the”–installed” option along with the “list”
dnf list --installed
Searching within the list of installed apps
Even, “dnf list –installed” would yield so many results, if you want to further narrow down your options you could use the “grep“ command with it, the “grep” command searches for a value within the output.
You could use grep command in combination with the list command like this:
dnf list --installed | grep [[package name]]
Want more help? No worries
The “help” option will help (ahm) you, it will list all the basic commands you possibly might need.
To use it enter the following command into the terminal.
dnf --help
if you have a more specific use case, you can always read the man pages of DNF using:
man dnf
Some Examples of installing popular apps using DNF
- Installing Firefox
sudo dnf install firefox
- Installing VLC media player
sudo dnf install vlc
- Installing GIMP
sudo dnf install gimp
Conclusion
Thats it! Now you know all the basic DNF commands to install, update, uninstall and do other things with apps. All you need to do now is to just open the terminal and start managing those nice packages with the new skills that you just learned. Let us know about the DNF commands you use most frequently in the comments. You can learn more about DNF in Fedora documentation or you could always read the man pages of DNF.
Contact Us