SSD Nodes Learn 🎉 VPS from $5.50/mo
How to do am Matt ConnorBy Matt Connor · Updated 2026-08-13

apt to dnf: Rocky and Fedora command equivalents

Move from apt to dnf on Rocky, AlmaLinux and Fedora. See direct command swaps plus repo setup, transaction rollback, package groups and unattended updates.

Di short answer

Moving from apt go dnf na mostly vocabulary change. apt install nginx dey become dnf install nginx. apt remove nginx dey become dnf remove nginx. apt update no get direct equivalent, because dnf dey refresh repository metadata by itself when cached copy don old. The easy part of the translation fit enter one screen. The useful part na the four operations wey no map at all: adding repository, undoing transaction, installing package group, and running unattended updates.

Every command below write for you to run for your own server. Read the transaction summary wey dnf print before you answer y, especially when na removal.

Which distros use dnf, and which use apt

dnf na the package manager for Fedora, Red Hat Enterprise Linux (RHEL), and the RHEL rebuilds: Rocky Linux, AlmaLinux and CentOS Stream. apt na the package manager for Debian and everything wey come from Debian, wey for VPS almost always mean Ubuntu. No third answer dey. If your provider image list get Rocky Linux or AlmaLinux, na dnf you go get. If e get Ubuntu, na apt you go get.

The package format dey follow the tool. dnf dey install .rpm files and e database na rpm. apt dey install .deb files and e database na dpkg. Na why many vendor install pages get one tab for each family, and why .deb wey you download from project release page no useful for Rocky Linux.

Any family wey you use, the first login na the same work. The first ten minutes for new VPS apply to both. Na only the install command dey change.

Every apt command and its dnf equivalent

Install, remove, search and show. Dem dey use almost the same words for both sides.

# apt
sudo apt install nginx
sudo apt remove nginx
apt search nginx
apt show nginx

# dnf
sudo dnf install nginx
sudo dnf remove nginx
dnf search nginx
dnf info nginx

apt show na dnf info. Na only verb wey change name for the group, but one behaviour dey different and e dey catch people. dnf remove still dey remove dependencies wey nothing else need, while apt remove dey leave dem installed for later apt autoremove. So, if you remove one small utility for Rocky Linux, e fit suggest say make e remove twelve libraries join am. Read the list before you confirm.

Refresh metadata, check wetin dey wait, and upgrade.

# apt
sudo apt update
apt list --upgradable
sudo apt install --only-upgrade nginx
sudo apt upgrade

# dnf
sudo dnf makecache
dnf check-update
sudo dnf upgrade nginx
sudo dnf upgrade

apt update compulsory for the apt side, because apt dey use any metadata wey dey disk and e go install version wey don leave the archive for months without complaint. dnf dey check how old its cache be before every transaction and e dey download fresh metadata by itself, so sudo dnf makecache na only to force that download make e happen now instead of during your next install.

apt dey split complete system upgrade into two, but dnf no dey do am. apt upgrade no gree remove any installed package, so e go stop whenever update need make one package comot. apt full-upgrade na the version wey fit remove package. dnf no get that restriction, which mean say dnf upgrade na equivalent of apt full-upgrade, no be apt upgrade. dnf update na old alias for the same command and e still dey work.

One detail important if you dey script this: dnf check-update dey exit with status 100 when updates dey wait, and 0 when no update dey. apt list --upgradable dey exit 0 for both cases, so scripts need parse its output.

List wetin dey installed, and find which package own a file.

# apt
dpkg -l
dpkg -S /usr/sbin/nginx
dpkg -L nginx
apt-file search /usr/sbin/nginx

# dnf
dnf list --installed
rpm -qf /usr/sbin/nginx
rpm -ql nginx
dnf provides /usr/sbin/nginx

The last line for each block dey answer different question from the lines above am. dpkg -S and rpm -qf dey search only packages wey already dey installed, so dem answer, “wetin put this file here”. apt-file search and dnf provides dey search the repositories, so dem answer, “which package I go install to get this file”. apt-file na separate package for Ubuntu and e need sudo apt-file update before the first run. dnf provides no need anything extra, though the first run fit slow because dnf dey download repository file lists to answer.

To list the files inside package wey you never install, use dnf repoquery -l nginx. For the apt side, na apt-file list nginx.

Autoremove, clean the cache, hold a version.

# apt
sudo apt autoremove
sudo apt clean
sudo apt-mark hold nginx
apt-mark showhold
sudo apt-mark unhold nginx

# dnf
sudo dnf autoremove
sudo dnf clean all
sudo dnf versionlock add nginx
dnf versionlock list
sudo dnf versionlock delete nginx

versionlock no dey installed by default for Rocky Linux or AlmaLinux, so the first line for that group go fail with No such command: versionlock for fresh box. Install am first with sudo dnf install python3-dnf-plugin-versionlock. apt no need anything extra for apt-mark hold, because hold na dpkg state, no be plugin.

Where mapping dey break: adding repository

Na this part dey make Ubuntu admins dey find command wey no exist. No add-apt-repository dey for dnf, and personal package archives (PPAs) no dey. PPA na service wey Launchpad dey run, and Launchpad na Ubuntu infrastructure. Nothing for RPM world dey host one.

Wetin dnf get instead na one plain text file for each repository inside /etc/yum.repos.d/, and each file dey end with .repo.

[docker-ce-stable]
name=Docker CE Stable
baseurl=https://download.docker.com/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

$releasever and $basearch na dnf variables. dnf go fill in your major release number and CPU architecture when e dey run. So the same file go work for version 9 and version 10, and for x86_64 and aarch64.

Most vendors dey publish that file and tell you to fetch am. Docker own instructions for RHEL and its rebuilds na two commands:

sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo

The first line dey there because config-manager na plugin, e no be part of dnf itself. If you skip am, the second line go fail with No such command: config-manager. Nothing stop you from downloading that same .repo file with curl into /etc/yum.repos.d/ by hand. The result go be identical. Installing Docker for VPS explain the Debian side of the same work, where the equivalent step dey write source list and signing key into two different directories.

The layout difference decide where you go look when repository get problem. apt dey keep definitions for /etc/apt/sources.list and /etc/apt/sources.list.d/, while signing keys dey separately under /etc/apt/keyrings/. dnf dey keep everything for /etc/yum.repos.d/, and the key na URL inside the .repo file. So na one file to read and one file to delete. Newer apt don move toward the same layout with deb822 format, one .sources file for each repository. If you don meet deb822 duplicate sources error for Ubuntu, you don already see the apt side of this problem.

EPEL na archive wey most guides dey assume

Extra Packages for Enterprise Linux (EPEL) na Fedora project wey dey build Fedora packages for RHEL and the rebuilds wey come from am. E be the closest thing this world get to universal PPA, and plenty tutorials assume say e don already enable. If dnf install answer No match for argument for package wey you fit see for the project own website, EPEL na the first thing to check.

For Rocky Linux and AlmaLinux:

sudo dnf config-manager --set-enabled crb
sudo dnf install epel-release
sudo dnf makecache

CRB na CodeReady Builder, repository wey get libraries wey come with the distribution but no dey enable by default. Most EPEL packages depend on something inside am, so enabling EPEL without CRB no go fail immediately. E go fail later, when you dey install, with unresolved dependencies on package wey you never hear before. Enable CRB first, and that kind error go disappear.

For RHEL itself, CRB dey come through your subscription instead of config-manager, so follow Red Hat own EPEL instructions for that step. Fedora no need any of this, because the main repository already get wetin EPEL backport. EPEL policy na say e no go ever replace package wey RHEL dey ship, so adding the repository no go change anything wey already dey installed for your server.

dnf history undo, the thing wey apt no fit do

dnf dey record every transaction, and e fit build reverse of one.

sudo dnf history
sudo dnf history info 42
sudo dnf history undo 42

dnf history dey print numbered list of transactions with the command line wey start each one. undo dey construct the opposite transaction: packages wey that transaction install go remove, and packages wey e upgrade go return to the version wey you get before. Na this feature apt users dey miss pass after dem switch.

E get real limits, and e good make you know dem before you rely on am. undo fit only reinstall package version wey still dey inside enabled repository. So, once mirror don remove the old build, the undo go fail with not-found error. Rollback still stop for package database. Config file wey upgrade rewrite go remain rewritten, and database schema wey service migrate for first start go remain migrated. dnf dey put the files back. E no dey put your data back.

apt no get equivalent. /var/log/apt/history.log dey record exactly wetin happen, including the command line, but to read log no be to undo am. Recovery for apt side na manual: run apt list -a nginx to see which versions archive still hold, then sudo apt install nginx=<exact version string> to pin one, and add sudo apt-mark hold nginx so the next upgrade no go undo your fix.

Package groups no get apt equivalent

dnf fit install a named set of packages with one command.

dnf group list
dnf group info "Development Tools"
sudo dnf group install "Development Tools"

Older guides dey write dnf groupinstall "Development Tools". That alias dey work for dnf 4 and e don disappear for dnf 5, so the two-word dnf group install na the only spelling wey dey work everywhere. Use am and no worry about am again.

apt no get groups. The closest idea for Debian na metapackage, an otherwise empty package wey only contain list of dependencies, like build-essential. The practical difference dey when you wan remove am: removing metapackage go leave the dependencies installed until you run apt autoremove, while dnf group remove go remove the group's packages together inside the same transaction.

unattended-upgrades and dnf-automatic

Both families get method to install updates when nobody dey logged in. The tools no get anything common apart from the purpose.

For Ubuntu and Debian, the package na unattended-upgrades. Dem configure am for /etc/apt/apt.conf.d/50unattended-upgrades, where you list the origins wey e fit pull updates from. How to set up unattended upgrades for Ubuntu explain that config file and the reboot question wey come with am.

For Rocky Linux, AlmaLinux and Fedora, the package na dnf-automatic. The systemd timer wey you enable go decide how e behaves.

sudo dnf install dnf-automatic
sudo systemctl enable --now dnf-automatic-install.timer
systemctl list-timers 'dnf-automatic*'

dnf-automatic-install.timer downloads and applies updates. dnf-automatic-download.timer downloads dem and stops, so you go install dem yourself. dnf-automatic-notifyonly.timer only reports. Each of these units overrides the apply_updates setting for /etc/dnf/automatic.conf, so the timer wey you choose matter pass wetin the config file talk.

To limit am to security fixes, set upgrade_type = security for /etc/dnf/automatic.conf. That filter depend on whether your repositories publish security errata, so first check with dnf updateinfo list security. If the result empty for a system wey get pending updates, e mean say the metadata no dey there. In that case, security no go install anything at all.

For Fedora, dnf 5 change the unit name. Na dnf5-automatic.timer, and e still dey read the same /etc/dnf/automatic.conf.

Yum still dey be real command?

Yes, and e no do anything by itself. For Rocky Linux, AlmaLinux and CentOS Stream, /usr/bin/yum na symbolic link wey dey point to dnf. Check your own one:

ls -l /usr/bin/yum
dnf --version

Old yum syntax still dey show for tutorials because most of dem still pass through directly. yum install, yum remove and yum update all dey work. One habit dey worth dropping: yum-config-manager still dey exist as im own binary for dnf 4 systems, but dnf config-manager na the spelling wey current documentation dey use, and na the one wey go continue to work when the box move to dnf 5.

dnf 4 and dnf 5: check before you copy a command

dnf 5 na rewrite, and e change how dem spell some commands. Fedora 41 and later dey ship am as dnf. The enterprise rebuilds never switch quick, so no guess based on the distribution name. Run dnf --version for your own server and read the first line, because na that number dey decide which syntax from below you need.

The clearest example come from Docker, wey publish different repository command for each one. For RHEL and the rebuilds wey come from am, with dnf 4:

sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo

For Fedora, with dnf 5:

sudo dnf config-manager addrepo --from-repofile https://download.docker.com/linux/fedora/docker-ce.repo

Na the same vendor and the same work, but the commands different. dnf 5 change config-manager into tool wey use subcommands, so e no accept the old --add-repo flag. Instead of repository, you go get usage error. The other one wey you go meet na how to enable repository: dnf config-manager --set-enabled crb for dnf 4 become dnf config-manager setopt crb.enabled=1 for dnf 5.

Choice wey really matter

Choosing server distribution based on package manager alone na wrong way to look am. dnf and apt do the same work, and you fit learn the terms within one afternoon. Wetin go affect your whole year na the release model behind the repository. Fedora dey move fast, and each release stop to receive updates around thirteen months after e come out. This fit work well for workstation, but e go cause wahala for server wey you no want rebuild. Rocky Linux and AlmaLinux follow RHEL, so you get ten-year support window and package versions wey intentionally no dey change often. Ubuntu get both options, and the difference between Ubuntu LTS and interim releases on a server na the same decision inside the apt ecosystem.

As of August 2026, all of dem na normal VPS images. Pick the support window wey you want, then learn the ten commands above.

FAQ

Wetin be the dnf equivalent of apt update?

You no need run any command. dnf dey check how old its cached metadata be before every transaction, and e dey download fresh copy when e don expire. So dnf install for server wey you never touch for one month still go see current packages. sudo dnf makecache dey exist and e dey force that download, but the real use na to move the delay go time wey you choose, instead of making e happen inside your next install. The command wey answer “wetin dey wait for me” na dnf check-update. E map to apt list --upgradable and e dey exit with status 100 when updates dey available.

PPA equivalent dey for Rocky Linux or Fedora?

No. Personal package archives na Launchpad service, and Launchpad na Ubuntu infrastructure, so add-apt-repository get nothing to translate into. The RPM equivalent na a .repo file inside /etc/yum.repos.d/, wey dey contain a name, a baseurl, and a gpgkey. Vendors dey publish that file for you, and sudo dnf config-manager --add-repo <url> for dnf 4, or sudo dnf config-manager addrepo --from-repofile <url> for dnf 5, dey download am into the correct place. For general extra software, the answer normally na EPEL. You fit enable am with sudo dnf config-manager --set-enabled crb followed by sudo dnf install epel-release.

I fit undo dnf upgrade wey spoil my server?

Yes, but e get limit. Run sudo dnf history to find the transaction number, sudo dnf history info <id> to see exactly wetin e change, then sudo dnf history undo <id>. The undo go fail if the old package version no dey again for any enabled repository, because dnf get nothing to reinstall from. E only reverse package changes too. If the upgrade rewrite configuration file, or service migrate database when e start for the first time, the change go remain as e be. apt no get equivalent command at all; na only the record for /var/log/apt/history.log dey.

yum still dey work for Rocky Linux and AlmaLinux?

E dey work because /usr/bin/yum na symbolic link to dnf. Confirm am for your own box with ls -l /usr/bin/yum. When you type yum install httpd, na dnf e dey run, so old tutorials mostly still dey work. For new scripts and documentation, write dnf, because the yum name na only for compatibility. Prefer dnf config-manager instead of the older yum-config-manager binary.

Why dnf remove wan delete plenty packages?

Because dnf dey remove dependencies wey nothing else need as part of the same transaction. apt remove dey leave dem installed until you run apt autoremove separately. So removal wey look small for Ubuntu fit print long list for Rocky Linux. The list normally correct, but read am before you confirm. If one package for the list na package wey you wan keep, install am explicitly first, so dnf go record say you want am for its own right.