Dandified YUM (DNF)
DNF, the powerful package manager used by Fedora, Red Hat Enterprise Linux (RHEL), and their derivatives.
Please note that the Linux shell is case-sensitive.
What is DNF?
DNF, short for Dandified YUM, is the next-generation version of the Yellowdog Updater, Modified (YUM) package manager for RPM-based distributions. It was designed to improve upon YUM in terms of performance, dependency resolution, and handling large numbers of packages.
Installing and Updating Packages
Installing a Package
To install a package using DNF, you use the install
command followed by the
package name. For example, to install nano
:
sudo dnf install nano
Removing a Package
To remove a package, you use the remove
command:
sudo dnf remove nano
Updating a Package
To update a specific package, you can use the update
command:
sudo dnf update nano
Updating All Packages
To update all installed packages to their latest versions:
sudo dnf update
Searching for Packages
Searching by Name
You can search for packages by name using the search
command:
dnf search nano
Searching by Description
If you’re not sure about the exact name of the package, you can search by description or other attributes:
dnf search editor
Managing Repositories
Adding a Repository
To add a new repository, you typically create a .repo
file in the
/etc/yum.repos.d/
directory. For example, to add a new repository:
sudo nano /etc/yum.repos.d/newrepo.repo
Then add the repository information to the file:
[newrepo]
name=New Repository
baseurl=http://repository.url/path/
enabled=1
gpgcheck=1
gpgkey=http://repository.url/path/RPM-GPG-KEY
Disabling a Repository
To disable a repository:
sudo dnf config-manager --set-disabled newrepo
Enabling a Repository
To enable a repository:
sudo dnf config-manager --set-enabled newrepo
Cleaning Up
Removing Unused Packages
Over time, you might accumulate packages that are no longer needed. To remove these orphaned packages:
sudo dnf autoremove
Cleaning Cache
DNF caches data for faster operations, but sometimes you need to clean this cache:
sudo dnf clean all
Additional Commands and Tips
Listing Installed Packages
To list all installed packages:
dnf list installed
Showing Package Information
To display detailed information about a package:
dnf info nano
Downloading Packages Without Installing
If you need to download a package without installing it (useful for offline installations):
dnf download nano
Group Installations
DNF supports installing groups of packages, which is handy for setting up environments. To list available groups:
dnf group list
To install a group:
sudo dnf group install "Development Tools"
History and Rollback
DNF keeps track of all transactions, making it possible to undo changes. To view the transaction history:
dnf history
To undo a specific transaction, use the transaction ID from the history:
sudo dnf history undo <transaction_id>
Best Practices
- Regular Updates: Keep your system updated regularly to ensure security and stability.
- Repository Management: Only enable repositories you trust and need.
- Cleanup: Regularly clean up unused packages and cache to free up space.
- Dependency Awareness: Be mindful of dependencies when installing or removing packages to avoid breaking your system.
Conclusion
DNF is a powerful and flexible package manager that makes managing software on
RPM-based systems a breeze. With these commands and tips, you should be able to
handle most of your package management needs efficiently. For more advanced
usage, the man dnf
command and the official
DNF documentation are great resources.
Happy package managing!
Last updated 22 Sep 2024, 12:15 CEST .