LinuxCommandLibrary

dnf-install

Install software packages

TLDR

Install packages by name

$ sudo dnf [[in|install]] [package1 package2 ...]
copy

Install a package from a local file
$ sudo dnf [[in|install]] [path/to/file]
copy

Install a package from the internet
$ sudo dnf [[in|install]] [https://example.com/package.rpm]
copy

Add the Extra Packages for Enterprise Linux (EPEL) repositories
$ sudo dnf [[in|install]] https://dl.fedoraproject.org/pub/epel/epel-release-latest-[10].noarch.rpm
copy

Add Remi's RPM repository
$ sudo dnf [[in|install]] https://rpms.remirepo.net/enterprise/remi-release-[8].rpm
copy

SYNOPSIS

dnf [global-options...] install [install-options...] package-spec [package-spec...]

PARAMETERS

--assumeyes, -y
    Automatically answer 'yes' to all prompts.

--allowerasing
    Permit erasing conflicting packages to resolve dependencies.

--best
    Install the best available package version (default).

--nobest
    Install any available version, not necessarily the best.

--downloadonly
    Download packages to cache but do not install.

--downloaddir=PATH
    Download packages to specified directory instead of cache.

--skip-broken
    Skip packages with unresolvable dependencies.

--enablerepo=repo
    Enable one or more repositories for this transaction.

--disablerepo=repo
    Disable one or more repositories for this transaction.

--releasever=VERSION
    Set value of $releasever variable.

--refresh, -r
    Update metadata cache before execution.

--setopt=option=value
    Override a configuration option.

DESCRIPTION

The dnf install command installs software packages, groups, or modules on RPM-based Linux systems using the DNF (Dandified YUM) package manager. DNF is the modern successor to YUM, utilized in distributions like Fedora, RHEL 8+, and CentOS Stream.

Executing dnf install <package> triggers dependency resolution using the powerful libsolv library, downloads RPMs from enabled repositories, verifies signatures, and installs them system-wide, typically requiring root privileges via sudo. It handles complex scenarios like obsoletes, conflicts, and modular streams intelligently.

Supports local RPM files (dnf install ./file.rpm), URLs, globs, or @group names for package groups (e.g., dnf groupinstall 'Development Tools'). Modular content via dnf module install is also possible, though install accepts module specs directly in newer versions.

DNF caches metadata for efficiency, refreshes with --refresh, and provides dry-run simulation via --assumeno. Post-install, it may suggest autoremoval of orphans. Ideal for servers and desktops, it ensures transactional updates for consistency.

CAVEATS

Requires root or sudo for installation. Large transactions consume significant bandwidth and disk space. Dependency resolution may erase packages unexpectedly without --allowerasing. Modular streams need explicit specification to avoid defaults.

EXAMPLES

sudo dnf install httpd - Install Apache web server.
sudo dnf install vim-enhanced vim-common - Install specific Vim packages.
sudo dnf groupinstall 'Development Tools' - Install compiler/group toolchain.
sudo dnf install --downloadonly gcc - Download without installing.

PACKAGE SPECS

Supports name/version (e.g., bash-5.*), file globs (kernel-*.rpm), groups (@group), modules (nodejs:18), or local paths/URLs.

HISTORY

DNF originated from Project Hawkey in 2012, entered experimental Fedora 18, and became default in Fedora 22 (2015). Backported to EPEL for RHEL/CentOS 7. Rewritten in C/Python with libsolv for speed over YUM.

SEE ALSO

dnf(8), dnf-update(1), dnf-remove(1), dnf-groupinstall(1), rpm(8), yum(1)

Copied to clipboard