DNF (Dandified YUM) is the default package manager for Fedora and other RPM-based Linux distributions. It handles installing, updating, removing, and querying software packages, and it resolves dependencies automatically. This guide walks through the essential DNF commands you need to manage packages on Fedora, from basic operations to troubleshooting.
Background: Why Fedora Uses DNF
Fedora adopted DNF in version 22 (2015) as the successor to YUM. DNF was built on the same principles but with a rewritten core that uses the libsolv dependency solver, which is faster and more memory-efficient. The name “Dandified” reflects its modernized architecture. DNF retains command-line compatibility with YUM for most common operations, so many older scripts still work, but it adds features like better transaction history, improved plugin support, and clearer error messages.
Basic Package Operations
These are the commands you’ll use most often. Run them in a terminal with sudo for any operation that changes the system.
sudo dnf install <package>– Installs a package and its dependencies. Use multiple names to install several at once.sudo dnf remove <package>– Removes a package, but keeps configuration files unless you use--purge(not recommended).sudo dnf update– Updates all installed packages to the latest available versions. On Fedora,upgradeis an alias for the same action.sudo dnf upgrade– Same asupdate; both work.sudo dnf downgrade <package>– Reverts a package to an older version (useful if a new version has a bug).sudo dnf autoremove– Removes packages that were installed as dependencies but are no longer needed by any installed package.
Searching and Querying Packages
Before installing, you often need to find the exact package name. DNF provides several search commands:
dnf search <keyword>– Searches package names and summaries.dnf info <package>– Shows detailed information: version, repository, size, description.dnf list installed– Lists all installed packages. Combine withgrepto filter:dnf list installed | grep vim.dnf list available– Lists packages available from enabled repositories.dnf provides <file>– Finds which package provides a specific file (e.g.,dnf provides /usr/bin/htop).dnf repoquery --requires <package>– Shows dependencies of a package (requires the dnf-plugins-core package).
Managing Repositories
Repositories are the sources from which DNF fetches packages. Fedora comes with several enabled by default (fedora, updates, and for older versions, updates-testing). You can add third-party repositories like RPM Fusion for non-free software.
dnf repolist– Lists enabled repositories and their counts.dnf repolist --all– Shows all repositories, including disabled ones.sudo dnf config-manager --add-repo <URL>– Adds a new repository from a .repo file URL (requires dnf-plugins-core).sudo dnf config-manager --set-enabled <repo-id>– Enables a disabled repository.sudo dnf config-manager --set-disabled <repo-id>– Disables a repository temporarily.
Be cautious when adding third-party repositories: they can conflict with Fedora’s packages or lack security updates. Always verify the repository’s trustworthiness.
Handling Common Problems
Even with a solid package manager, issues arise. Here are typical scenarios and how to address them.
- Dependency conflicts: If DNF reports conflicts, try
sudo dnf update --refreshto get the latest metadata, or usesudo dnf distro-syncto align installed packages with the repository versions. - Broken transaction: If a previous operation was interrupted, run
sudo dnf clean allto clear cached metadata, thensudo dnf updateagain. - Package not found: Ensure the repository is enabled (
dnf repolist) and the package name is correct. Usednf searchto verify. - Locked database: If another process is using DNF (like a system update), wait or kill the process, but never delete the lock file manually unless you’re certain it’s stale.
- Kernel updates: After updating the kernel, you must reboot to use it. DNF keeps old kernels so you can boot into a previous one if needed.
DNF vs. Other Package Managers
Fedora’s DNF is one of several package managers in the Linux world. Understanding the differences helps when moving between distributions.
- APT (Debian/Ubuntu): Uses .deb packages and a different dependency solver. Commands are similar (
apt install), but the ecosystem differs. - Pacman (Arch): Uses .pkg.tar.zst packages and a rolling-release model. Pacman is faster but lacks some of DNF’s history and rollback features.
- Zypper (openSUSE): Uses RPM packages like Fedora, but with a different front-end. Zypper has a similar command structure.
- Flatpak and Snap: These are containerized applications that work across distributions. They are not replacements for DNF but complement it for GUI apps.
DNF’s advantage is its robust dependency resolution and transaction history, which allows you to undo changes with sudo dnf history undo <id>.
Advanced DNF Features
For power users, DNF offers features that go beyond basic install/remove.
- Transaction history:
sudo dnf historyshows past operations. You can view details withsudo dnf history info <id>and roll back withsudo dnf history rollback <id>. - Groups: Install a group of packages, e.g.,
sudo dnf groupinstall "Development Tools". List groups withdnf group list. - Download without installing:
sudo dnf download <package>downloads the RPM file to the current directory (requires dnf-plugins-core). - Clean cache:
sudo dnf clean allremoves cached package data. This can fix issues and free space. - Check for updates:
dnf check-updateexits with a status code that can be used in scripts (0 if no updates, 100 if updates available).
Frequently Asked Questions
How do I update all packages on Fedora?
Run sudo dnf update (or sudo dnf upgrade). This will refresh the repository metadata and install all available updates. It’s a good idea to do this regularly to keep your system secure.
What does ‘sudo dnf autoremove’ do?
It removes packages that were installed automatically as dependencies but are no longer required by any installed package. This helps clean up orphaned packages and free disk space. It’s safe to run periodically.
Why do I get a ‘Could not resolve host’ error when using dnf?
This usually means your internet connection is down or the repository URL is unreachable. Check your network, then try sudo dnf clean all and sudo dnf update again. If the issue persists, check the repository configuration in /etc/yum.repos.d/.
Can I use DNF to install a specific version of a package?
Yes, use sudo dnf install <package>-<version>. For example, sudo dnf install vim-enhanced-8.2.1234. You can see available versions with dnf --showduplicates list <package>.
How do I remove a package and its configuration files?
DNF’s remove command keeps configuration files by default. To remove them as well, you can manually delete the config files afterward, or use sudo dnf remove --purge <package> (though this is not always supported). For most cases, the default is fine.
Is DNF the same as YUM?
DNF is the successor to YUM. Many commands are similar, but DNF has a different underlying architecture and improved performance. On Fedora, yum is a symlink to DNF for compatibility, but you should use dnf for new scripts and habits.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Delete Picture Kik? How to Remove Photos
- What Happens to X Replies, DMs, and Followers After Deletion?
- Data Breaches That Shook the World
- Disable Google Assistant: Turn It Off on Android & Home
- Resin vs FDM Printers for Miniatures: Detail, Durability, Cost
- Are Networked Implants Safe? What If One Fails?