
Managing software packages is a fundamental task on Linux systems, and tools like DNF (Dandified YUM) make this process straightforward. DNF is the next-generation package manager for RPM-based distributions such as Fedora, CentOS Stream, and RHEL (Red Hat Enterprise Linux), serving as a successor to the well-known YUM utility. While YUM is still present in some older systems or for compatibility, DNF is now the standard and offers improved performance and dependency resolution.
Using a package manager simplifies installing, updating, and removing software. Instead of manually downloading and compiling source code, you interact with repositories – centralized locations where software packages are stored. DNF fetches packages from these repositories, automatically handling dependencies to ensure that all required components are installed.
Here are essential commands for working with DNF:
To perform most package management tasks, you will need administrative privileges, typically using the sudo
command before your DNF commands.
Searching for Packages
Finding the software you need is easy. Use the search
command:
sudo dnf search package_name
Replace package_name
with the name or keyword of the software you’re looking for. This command lists all packages whose names or descriptions match your query.
Installing Packages
Once you’ve found the package, install it using the install
command:
sudo dnf install package_name
DNF will show you the package(s) to be installed, including any dependencies, and ask for confirmation before proceeding.
Updating Packages
Keeping your system and software updated is crucial for security and stability.
To update a specific package:
sudo dnf update package_name
To update all installed packages on your system:
sudo dnf update
This command checks all configured repositories for newer versions of your installed software and prompts you to upgrade.
Removing Packages
If you no longer need a software package, you can remove it:
sudo dnf remove package_name
DNF will uninstall the specified package. Be cautious with this command, as removing certain packages might affect other software that depends on them.
Checking Package Information
Sometimes you need more details about a package before installing it or just to understand what an installed package does. Use the info
command:
dnf info package_name
This displays information like the package description, version, size, and dependencies. You typically don’t need sudo
for just viewing information.
Listing Installed and Available Packages
To see all packages currently installed on your system:
dnf list installed
To see all packages available in your configured repositories:
dnf list available
These lists can be quite long. You can pipe the output to commands like grep
to filter the results. For example, dnf list installed | grep mysql
.
Managing Repositories
DNF gets packages from repositories defined in configuration files, usually located in /etc/yum.repos.d/
.
To list the repositories DNF is configured to use:
dnf repolist
This shows information about enabled repositories, including their ID and name.
To see more detailed information about repositories:
dnf repolist all
Cleaning the Cache
DNF downloads package headers and metadata to a cache. Sometimes, cleaning this cache can help resolve issues or free up disk space.
sudo dnf clean packages
(Cleans downloaded packages)
sudo dnf clean metadata
(Cleans repository metadata)
sudo dnf clean all
(Cleans both packages and metadata)
Understanding and utilizing DNF commands effectively is key to maintaining a healthy and up-to-date Linux system based on RPM distributions. These basic commands cover the most common package management tasks you’ll encounter.
Source: https://ostechnix.com/dnf5-commands-examples/