DNF is the package manager of the RHEL family, and Rocky Linux 9 gets most of its extra software from third-party repositories. Knowing how to enable the EPEL repository on Rocky Linux 9 — plus CRB and Remi — unlocks thousands of additional packages: monitoring tools, extra PHP versions, Fail2Ban and much more. This guide starts with the DNF commands you will use daily, then enables each repository safely. This article covers DNF and Repositories on Rocky Linux in detail.
Everyday DNF Commands – DNF and Repositories on Rocky Linux
If you used YUM on CentOS, DNF will feel familiar — yum is even kept as a compatibility alias.
sudo dnf upgrade -y # update everything
sudo dnf install htop # install a package
sudo dnf remove htop # remove a package
dnf search fail2ban # search repositories
dnf info nginx # show package details
dnf list installed # what is installed?
sudo dnf history # past transactions
sudo dnf history undo 12 # roll back a transaction
sudo dnf clean all # clear caches after repo changes
DNF’s transaction history is a lifesaver: when an update breaks something, history undo and history rollback let you revert cleanly instead of reinstalling packages by hand.
Module Streams: One Package, Several Versions – DNF and Repositories on Rocky Linux
Rocky ships some software in module streams so you can pick a version line, for example PHP or Node.js:
dnf module list php
sudo dnf module reset php
sudo dnf module enable php:8.1
sudo dnf install -y php
Resetting a module before switching avoids the dependency conflicts that otherwise appear with confusing error messages.
Repository Management Basics
dnf repolist
dnf repolist --all
sudo dnf config-manager --set-disabled docker-ce-stable
ls /etc/yum.repos.d/
Repository definitions live in /etc/yum.repos.d/. Never edit the files shipped by release packages directly if you can avoid it — use dnf config-manager so your changes survive updates.

Enable the EPEL Repository on Rocky Linux 9
EPEL (Extra Packages for Enterprise Linux) is maintained by the Fedora project and is the first repository most administrators add. It is a single package:
sudo dnf install -y epel-release
dnf repolist | grep epel
sudo dnf makecache
sudo dnf install -y htop fail2ban
EPEL is designed not to replace packages from the base repositories, which makes it safe for production systems. The official EPEL documentation explains its policies. Many guides on this site, including our Rocky Linux 9 server setup, rely on EPEL for Fail2Ban.
Enable CRB (CodeReady Builder)
Some EPEL packages depend on development libraries that Rocky keeps in the CRB repository — the equivalent of RHEL’s CodeReady Builder. Enable it when a dependency is reported missing:
sudo dnf config-manager --set-enabled crb
dnf repolist | grep crb
On Rocky Linux 8 the same repository was called PowerTools; on version 9 it is simply crb.
Add the Remi Repository for Newer PHP
Rocky’s default PHP is stable but not the newest. The Remi repository provides current PHP versions as module streams:
sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm
sudo dnf module reset php
sudo dnf module install php:remi-8.3
php -v
The Remi repository site documents every available stream. This is the cleanest way to run modern PHP for the LEMP stack on Rocky Linux 9 without compiling anything.
Lock a Package Version with versionlock
When a specific application needs an exact version, prevent DNF from upgrading it:
sudo dnf install -y python3-dnf-plugin-versionlock
sudo dnf versionlock add mariadb-server
sudo dnf versionlock list
Troubleshooting
- “No match for argument” even though the package exists: the repository is disabled or the cache is stale. Run
dnf repolistandsudo dnf makecache. - GPG key import failures: you added a repo file manually without its key. Import the vendor key with
rpm --importusing the URL from the vendor’s site — never disable GPG checks globally. - Modular dependency errors: a module stream is pinned. Run
dnf module reset <name>and retry. - Errors mentioning file conflicts with Podman or other packages: note the exact packages; DNF will usually solve it if you remove the conflicting package first, as in our Docker on Rocky Linux 9 guide.
Groups, Autoremove and Repo Queries
Three more DNF features round out daily work. Groups install curated sets of packages — for example a build environment:
dnf group list
sudo dnf group install -y "Development Tools"
sudo dnf group install -y "System Tools"
Autoremove cleans up dependencies that are no longer needed after you uninstall software, keeping the system lean:
sudo dnf autoremove -y
And repoquery answers questions before you install anything — which package provides a file, or what a package requires:
dnf repoquery --whatprovides /usr/bin/htop
dnf repoquery --requires fail2ban
Together these commands turn DNF from a simple installer into a proper inventory tool for the whole system.
Conclusion
With DNF basics mastered and the EPEL repository on Rocky Linux 9 enabled alongside CRB and Remi, you have access to a huge, well-maintained software library. Keep the number of third-party repositories small, prefer EPEL where possible, and your system will stay stable through years of updates — the Rocky Linux documentation has a full package management chapter for further reading.