How to Use dnf: The Package Manager for AlmaLinux & Rocky Linux

dnf (Dandified YUM) is the package manager for AlmaLinux, Rocky Linux, and other RHEL-family distributions — the equivalent of apt on Ubuntu/Debian. This guide covers the essential commands.

Updating the System

sudo dnf update -y

Unlike apt's separate update/upgrade steps, dnf's update command refreshes metadata and installs updates together.

Installing a Package

sudo dnf install nginx -y

Installing Multiple Packages

sudo dnf install nginx mariadb-server php -y

Removing a Package

sudo dnf remove nginx

Searching for a Package

dnf search nginx

Getting Information About a Package

dnf info nginx

Listing Installed Packages

dnf list installed

Checking for Available Updates

dnf check-update

Removing Unused Dependencies

sudo dnf autoremove

Cleaning the Package Cache

sudo dnf clean all

Enabling Extra Repositories (EPEL)

Many useful packages aren't in the default repositories — the EPEL (Extra Packages for Enterprise Linux) repository fills this gap:

sudo dnf install epel-release -y
sudo dnf update -y

Adding a Third-Party Repository

sudo dnf config-manager --add-repo https://example.com/repo.repo

Listing Enabled Repositories

dnf repolist

Installing a Specific Package Version

sudo dnf install nginx-1.24.0 -y

Downgrading a Package

sudo dnf downgrade nginx

Viewing Package Groups

dnf group list

Package groups bundle related software (e.g. "Development Tools") for convenient installation:

sudo dnf group install "Development Tools" -y

Checking Which Package Provides a Specific File

dnf provides /usr/bin/nginx

Viewing Transaction History

sudo dnf history

Undo a specific transaction:

sudo dnf history undo LAST

Automatic Security Updates

sudo dnf install dnf-automatic -y
sudo systemctl enable --now dnf-automatic.timer

Configure to apply only security updates:

sudo nano /etc/dnf/automatic.conf
upgrade_type = security
apply_updates = yes

Quick Reference: apt vs dnf

Taskapt (Ubuntu/Debian)dnf (AlmaLinux/Rocky)
Update systemapt update && apt upgradednf update
Installapt install PKGdnf install PKG
Removeapt remove PKGdnf remove PKG
Searchapt search PKGdnf search PKG
Clean cacheapt cleandnf clean all

Common Errors

"No match for argument" when installing — the package may be in a repository not yet enabled; try enabling EPEL first.

Dependency conflicts:

sudo dnf install PACKAGE --allowerasing

Continue Reading

Browse more articles in AlmaLinux & Rocky Linux.

  • dnf, almalinux package manager, rocky linux dnf, epel repository
  • 0 Korisnici koji smatraju članak korisnim
Je li Vam ovaj odgovor pomogao?

Vezani članci

AlmaLinux vs Rocky Linux vs CentOS: What Happened to CentOS?

If you're choosing a RHEL-compatible Linux distribution for your VPS, understanding the CentOS...

How to Get Started with AlmaLinux/Rocky Linux on a VPS

This guide covers the essential first steps after deploying a new AlmaLinux or Rocky Linux VPS...

How to Configure firewalld on AlmaLinux/Rocky Linux

firewalld is the default firewall management tool on AlmaLinux and Rocky Linux, using a...

How to Install Nginx on AlmaLinux/Rocky Linux

This guide covers installing and configuring Nginx on AlmaLinux or Rocky Linux, including the...

How to Install Apache (httpd) on AlmaLinux/Rocky Linux

On RHEL-family distributions, Apache is packaged as httpd rather than apache2 — a naming...