How to use the command dnf5 (with examples)
- Linux
- December 17, 2024
DNF5 is a state-of-the-art package management utility designed for distributions such as Red Hat Enterprise Linux (RHEL), Fedora, and CentOS. Replacing its predecessors dnf
and yum
, DNF5 offers a C++ rewrite that promises enhanced performance and reduced size. It is crucial for managing software packages, including tasks like installation, upgrade, and removal. DNF5 streamlines software management on these Linux distributions, providing users the tools needed to maintain their system efficiently.
Use case 1: Upgrade installed packages to the newest available versions
Code:
sudo dnf5 upgrade
Motivation:
Keeping software packages up to date is crucial for security, performance, and accessing the latest features. Regularly upgrading installed packages helps in keeping your system stable and secure against vulnerabilities that might be present in older versions. By using DNF5 to handle these upgrades, users ensure a smoother experience with fewer manual interventions.
Explanation:
sudo
: This prefix is used to execute the command with superuser privileges. Since upgrading software affects all users and the overall system security, it requires administrative access.dnf5
: It is the command-line package manager for handling software on RHEL, Fedora, and CentOS.upgrade
: This argument tells DNF5 to upgrade all currently installed packages to the newest versions available in the repositories.
Example Output:
Last metadata expiration check: 0:20:00 ago on Tue Sep 19 10:22:44 2023.
Dependencies resolved.
Nothing to do.
Complete!
Use case 2: Search packages via keywords
Code:
dnf5 search keyword1 keyword2 ...
Motivation:
Locating specific packages or software that perform a certain task can be daunting given the multitude of options available in package repositories. This command helps users quickly identify packages that could be of interest by searching through the package names and descriptions using keywords.
Explanation:
dnf5
: The package manager command utilized for searching, installing, and managing packages.search
: This argument is used to initiate a search operation within the available package repositories.keyword1 keyword2 ...
: These are the terms that the command uses to filter search results. DNF5 will return any package that matches any of the specified keywords in its name or description.
Example Output:
=======================================================
Name : git
Version : 2.41.0
Summary : Distributed version control system
...
Name : git-cola
Version : 4.0.3
Summary : Git GUI
...
Use case 3: Display details about a package
Code:
dnf5 info package
Motivation:
Understanding the specifics of a software package can be vital for making informed decisions about whether to install or use it. This command is helpful when users need to see detailed information about a package, such as its version, size, installation status, and a brief summary of its functionality.
Explanation:
dnf5
: The RPM package management tool used here for information retrieval.info
: The command’s argument for displaying detailed information about a particular package.package
: Placeholder for the name of the package whose details are being queried.
Example Output:
Name : vim
Version : 9.0.0500
Release : 1.fc37
Architecture : x86_64
Size : 5.2 M
Source : vim-9.0.0500-1.fc37.src.rpm
Repository : updates
Summary : The VIM editor
URL : http://www.vim.org/
License : Vim
Description : VIM (VIsual editor iMproved) is an updated and improved version of the
: vi editor.
Use case 4: Install new packages
Code:
sudo dnf5 install package1 package2 ...
Motivation:
Installing new software is a fundamental task for any computer system, allowing users to extend the functionality of their environment with additional applications and tools. This command facilitates the acquisition of new software by handling dependencies and package retrieval automatically.
Explanation:
sudo
: Executed with superuser privileges to allow the installation of new software system-wide.dnf5
: The package manager responsible for resolving dependencies and fetching packages from the repository.install
: This argument tells DNF5 to install the specified packages.package1 package2 ...
: These are the names of the packages the user wishes to install.
Example Output:
Dependencies resolved.
Installing:
package1
package2
...
Complete!
Use case 5: Remove packages
Code:
sudo dnf5 remove package1 package2 ...
Motivation:
When a software package is no longer needed or is causing conflicts or issues, removing it from the system is often necessary. This command allows users to cleanly remove unwanted or unused packages to free up resources and maintain a tidy system environment.
Explanation:
sudo
: Provides administrative rights to execute the command and modify system software.dnf5
: The management utility for handling the removal operation.remove
: This argument instructs DNF5 to delete specified software packages along with their dependencies.package1 package2 ...
: These are the package names targeted for removal.
Example Output:
Dependencies resolved.
Removing:
package1
package2
...
Complete!
Use case 6: List installed packages
Code:
dnf5 list --installed
Motivation:
Knowing what software is currently installed on a system can help users manage and audit their software inventory effectively. This information aids in tracking software usage, diagnosing issues, and planning necessary updates or removals.
Explanation:
dnf5
: The package management tool used for listing operations.list
: This argument is used to initiate a listing of available or installed packages.--installed
: A flag that limits the listing to those packages that are currently installed on the system.
Example Output:
Installed Packages
vim.x86_64 9.0.0500-1.fc37 @updates
git.x86_64 2.41.0-1.fc37 @updates
...
Use case 7: Find which packages provide a given command
Code:
dnf5 provides command
Motivation:
When trying to execute a command that doesn’t exist on the system, determining which package supplies it is essential for resolving the issue. This command helps identify the missing software package needed to execute a command.
Explanation:
dnf5
: The package manager tool, used here for querying capability.provides
: A function to locate the package providing a specified command or file.command
: The command or file for which the package information is being sought.
Example Output:
package-name-2.3.1.x86_64 : Provides the desired command/functionality
Repo : repository-name
Matched from:
Filename : /usr/bin/command
Use case 8: Remove or expire cached data
Code:
sudo dnf5 clean all
Motivation:
Over time, package managers accumulate cache information that can consume disk space. Removing or expiring cache data is necessary to ensure system storage efficiency and sometimes resolve issues related to stale metadata.
Explanation:
sudo
: Allows the execution of the command with superuser privileges, necessary for making system changes such as clearing caches.dnf5
: The package manager tool being used.clean
: The operation intended to remove cached data.all
: Cleans all cached data, including metadata and package caches.
Example Output:
24 files removed
Conclusion:
The dnf5
package management utility offers a powerful set of functions for maintaining and managing software packages on RHEL, Fedora, and CentOS systems. From installing and removing packages to upgrading and performing system audits, each command serves a specific purpose designed to enhance user productivity and system cleanliness. By mastering these commands, users can ensure a robust and efficient Linux environment tailored to their needs.