LinuxCommandLibrary

dnf

Manage and install software packages

TLDR

Upgrade installed packages to the newest available versions

$ sudo dnf [[up|upgrade]]
copy

Search packages via keywords
$ dnf [[se|search]] [keyword1 keyword2 ...]
copy

Display details about a package
$ dnf [[if|info]] [package]
copy

Install a new package (use --assumeyes to confirm all prompts automatically)
$ sudo dnf [[in|install]] [package1 package2 ...]
copy

Remove a package
$ sudo dnf [[rm|remove]] [package1 package2 ...]
copy

List installed packages
$ dnf [[ls|list]] --installed
copy

Find which packages provide a given command
$ dnf [[wp|provides]] [command]
copy

View all past operations
$ dnf [[hist|history]]
copy

SYNOPSIS

dnf [options] command

PARAMETERS

--assumeyes, -y
    Automatically answer yes for all questions. Useful for scripting.

--nogpgcheck
    Disable GPG signature checking for all packages during the transaction.

--enablerepo=repo_id
    Enable a specific repository for the current transaction, even if disabled in configuration.

--disablerepo=repo_id
    Disable a specific repository for the current transaction, even if enabled in configuration.

--refresh
    Force a refresh of all metadata before executing the command, ensuring up-to-date repository information.

--downloadonly
    Download packages but do not install them. Useful for offline installations.

--setopt=option=value
    Set a specific configuration option directly. E.g., install_weak_deps=False.

DESCRIPTION

dnf, which stands for Dandified YUM, is the default package manager for RPM-based Linux distributions like Fedora, Red Hat Enterprise Linux (RHEL) 8+, and CentOS Stream.

It is the successor to YUM (Yellowdog Updater, Modified) and aims to address many of YUM's shortcomings, particularly in terms of performance, dependency resolution, and API extensibility. dnf uses libsolv for dependency resolution, which generally results in faster and more accurate calculations for package installations, updates, and removals.

dnf provides a robust command-line interface for managing software packages, including searching, installing, updating, removing, and querying packages. It supports various features such as modularity (allowing different streams of software to be installed), rich dependency information, and advanced repository management. Its design is more modern and maintainable, making it a preferred tool for system administrators and users alike on supported distributions.

CAVEATS

While dnf is generally reliable, incorrect repository configurations or using options like --nogpgcheck can compromise system security. Be cautious with commands that remove packages (dnf remove or dnf autoremove), as they can inadvertently remove critical system components if dependencies are misinterpreted or manually overridden. Always review the transaction summary before confirming changes.

COMMON <I>DNF</I> COMMANDS

dnf offers a wide range of subcommands for various package management tasks:
install package_name: Installs a package and its dependencies.
update: Updates all installed packages to their latest available versions.
remove package_name: Removes an installed package.
search keyword: Searches for packages containing the specified keyword in their name or summary.
info package_name: Displays detailed information about a package.
repolist: Lists all configured software repositories and their status (enabled/disabled).
autoremove: Removes all unused dependency packages that were installed automatically and are no longer required.

MODULARITY

A key feature introduced with dnf and prominent in RHEL 8+ is modularity. It allows for the installation of different streams or versions of software (e.g., Python 3.6 vs. Python 3.8, or different versions of Node.js) on the same system, providing greater flexibility and avoiding conflicts often seen in traditional package management where only one global version of a library or application could exist. Users can 'enable' specific module streams to install their preferred version of software.

HISTORY

dnf was developed as a successor to YUM, addressing long-standing performance and dependency resolution issues inherent in YUM's design. It first appeared in Fedora 18 (2012) and officially became the default package manager in Fedora 22 (2015). The transition from YUM to dnf marked a significant evolution in package management for RPM-based distributions, driven by a desire for a more modern, maintainable, and extensible codebase, leveraging Python 3 and the libsolv library for its robust dependency solver. It was subsequently adopted by Red Hat Enterprise Linux 8+ and CentOS Stream, solidifying its position as the standard package manager for these systems.

SEE ALSO

yum(8), rpm(8), apt(8), zypper(8)

Copied to clipboard