Managing Packages with dnf
dnf (Dandified YUM) is the package manager for Red Hat-based distributions: CentOS, AlmaLinux, Rocky Linux, and Fedora.
Update Package Lists and Upgrade
dnf update -y
Install a Package
dnf install nginx -y
Remove a Package
dnf remove nginx
Search for a Package
dnf search nginx
Show Package Information
dnf info nginx
List Installed Packages
dnf list installed
dnf list installed | grep php
Enable EPEL Repository
EPEL (Extra Packages for Enterprise Linux) provides many packages not in the default repos:
dnf install epel-release -y
Enable Remi Repository (for latest PHP)
dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm -y
dnf module enable php:remi-8.2 -y
List Available Module Streams
dnf module list
Clean Cache
dnf clean all
Check for Broken Dependencies
dnf check
Downgrade a Package
dnf downgrade nginx
View dnf History
dnf history
dnf history undo last # Undo last transaction