SSD Nodes Learn Hosting plans →
How to do am Matt ConnorBy Matt Connor · Updated 2026-10-21

apt to dnf: Rocky and Fedora command equivalents

See the dnf equivalent for every apt command, plus Rocky, AlmaLinux and Fedora repository setup, package groups, rollback and unattended update gotchas.

Di short answer

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

Every command below na for you to run on your own server. Read di transaction summary wey dnf print before you answer y, especially when packages dey remove.

Which distros dey use dnf, and which ones dey 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, and for VPS, this almost always mean Ubuntu. No third answer dey. If your provider image list get Rocky Linux or AlmaLinux, you dey get dnf. If e get Ubuntu, you dey get apt. Why one side of this split get four names for system wey mostly dey the same na story wey worth knowing before you choose between dem, and how Red Hat Linux become Fedora, RHEL, CentOS, Rocky and AlmaLinux explain where each one come from.

The package format 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 plenty vendor install pages get one tab for each family, and why a .deb wey you download from project release page no go install with dnf for Rocky Linux. The alien tool, wey dem package for EPEL 9, fit convert one into .rpm, but dem no build the result against your system libraries, so first look for the project own RPM.

Any family wey you choose, 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 get different name for this group, but one behaviour dey different and e dey catch people unaware. 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 matter more for the apt side, because apt dey work with any metadata wey dey for disk and e no refresh am when you run apt install or apt upgrade. If the lists old, apt no know about newer versions, and e fit ask the mirror for file wey don comot from the archive. When that one happen, download go fail and nothing go install. Run apt update first and both problems go comot. 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 full system upgrade into two, but dnf no dey do that. apt upgrade no gree remove any installed package, so e stop whenever update need make one package comot. apt full-upgrade na the version wey fit remove package. dnf no get that restriction, so dnf upgrade na the equivalent of apt full-upgrade, no be of apt upgrade. dnf update na old alias for the same command and e still dey work.

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

List wetin don install, and find out 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 don already install, so dem dey answer “wetin put this file here”. apt-file search and dnf provides dey search the repositories, so dem dey 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 its first run. dnf provides no need anything extra, though the first run fit slow because dnf dey download the repository file lists to answer the question.

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

For dnf 4, versionlock na plugin, and Rocky Linux or AlmaLinux no install am by default, so the first line among those lines go fail with No such command: versionlock for fresh box. Install am first with sudo dnf install python3-dnf-plugin-versionlock. For Fedora, dnf 5 get versionlock built in as normal command, so you no need install anything. apt no need anything extra for apt-mark hold, because hold na dpkg state, no be plugin.

Mapping wey break: how to add repository

Na this part dey make Ubuntu admins search for command wey no dey exist. No add-apt-repository dey for dnf, and personal package archives (PPAs) no dey too. 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 distribution release version and CPU architecture when e dey run. Rocky Linux dey set release version to only the major number, like 9 or 10. 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, and the result go be the same. How to install Docker for VPS explain the Debian side of the same work, where the equivalent step dey write a source list and signing key into two different directories.

The layout difference decide where you go check when repository no dey work well. 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 .repo file, so na one file you need read and one file you need delete. Newer apt don move toward the same structure with deb822 format, with one .sources file for each repository. If you don encounter deb822 duplicate sources error for Ubuntu, you don already meet the apt side of this problem.

EPEL na di archive wey most guides assume

Extra Packages for Enterprise Linux (EPEL) na Fedora project wey dey build Fedora packages for RHEL and its rebuilds. Na di closest thing this world get to universal PPA, and plenty tutorials assume say you don enable am already. If dnf install answer No match for argument for package wey you fit see for di project own website, EPEL na di 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 of libraries wey dey ship with di distribution but no dey enabled by default. Most EPEL packages depend on something inside am, so enabling EPEL without CRB no go fail for dat moment. E go fail later, for install time, with unresolved dependencies on package wey you never hear about before. Enable CRB first, and dat kind error go disappear.

For RHEL itself, CRB dey come through your subscription instead of through config-manager, so follow Red Hat own EPEL instructions for dat step. Fedora no need any of dis, because its main repository already carries wetin EPEL backports. EPEL policy na to never replace package wey RHEL dey ship, so adding di repository no go change anything wey already dey installed for your server.

dnf history undo, di tin wey apt no fit do

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

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

dnf history dey print numbered list of transactions wit di command line wey start each one. undo dey construct di opposite transaction: packages wey dat transaction install go comot, and packages wey e upgrade go go back to di version wey you bin get before. Dis na di feature wey apt users dey miss pass when dem switch.

E get 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 dem comot di old build from di mirror, di undo go fail wit not-found error. Rollback sef dey stop for package database. Config file wey upgrade rewrite go still dey rewritten, and database schema wey service migrate for first start go still dey migrated. dnf dey put di files back. E no dey put your data back.

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

Package groups no get apt equivalent

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

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

Old guides dey write dnf groupinstall "Development Tools". That alias dey work for dnf 4 but e no dey 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 things for Debian na metapackage, wey be package wey almost empty and only content na list of dependencies, like build-essential, and task package, like task-gnome-desktop, wey install complete desktop environment with one install. None of dem give you dnf group commands. The practical difference dey show when you remove am: removing metapackage leaves the dependencies installed until you run apt autoremove, while dnf group remove removes the group's packages together for the same transaction.

unattended-upgrades and dnf-automatic

Both package family get method to install updates when nobody dey logged in. Apart from this purpose, dem no share anything.

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 on Ubuntu explain that config file and the reboot question wey come with am.

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

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 but stops, so na you go install dem. dnf-automatic-notifyonly.timer only reports. Each unit dey override the apply_updates setting for /etc/dnf/automatic.conf. Because of this, the timer wey you choose matter pass wetin the config file talk. Installing update no restart process wey still dey run old code. So check which updates need reboot and which ones only need service restart before you assume say the box don patch.

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

For Fedora, dnf 5 don replace this setup. The package na dnf5-plugin-automatic, and the three units above no dey again. dnf 5 ship one dnf5-automatic.timer only. /etc/dnf/automatic.conf decide wetin e go do, and e read that setting on top of the defaults for /usr/share/dnf5/dnf5-plugins/automatic.conf.

Yum still be real command?

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

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

Old yum syntax still dey show for tutorials sake of say most of am still dey work direct. yum install, yum remove and yum update all dey work. One habit wey you suppose stop: yum-config-manager still dey as im own binary for dnf 4 systems, but dnf config-manager na the spelling wey current documentation dey use, and na that one go still dey work when the box move go dnf 5.

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

dnf 5 na rewrite, and e change how dem dey spell plenty command. Fedora 41 and versions wey come after am dey use dnf. Enterprise rebuilds dey slow to switch, so no guess based on distribution name. Run dnf --version for your server and check the first line, because that number go tell you which syntax you suppose use from the ones wey dey below.

The best example na Docker, wey get different repository command for each one. For RHEL and im rebuilds, if you dey use dnf 4:

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

For Fedora, if you dey use dnf 5:

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

Same vendor, same work, different words. dnf 5 change config-manager make am be tool wey dey use subcommand, so the old --add-repo flag no go work again and you go see usage error instead of repository. Another one wey you go see na how to enable repository: dnf config-manager --set-enabled crb for dnf 4 don turn to dnf config-manager setopt crb.enabled=1 for dnf 5.

The choice wey actually matter

To pick server distribution based on package manager alone na wrong way to reason. dnf and apt dey do the same work, and you fit learn the vocabulary for one afternoon. Wetin go change your year na the release model wey dey behind the repository. Fedora dey move fast and any release go stop to dey get updates roughly thirteen months after e show, wey dey okay for workstation but e dey pain for server wey you no want rebuild. Rocky Linux and AlmaLinux dey follow RHEL, so you go get ten year support window and package versions wey dey stay one place intentionally. Ubuntu get both types, and the difference between Ubuntu LTS and interim releases for server na the same decision wey you go make inside the apt world.

As of August 2026, all these ones na ordinary VPS images. Pick the support window wey you want, then learn the ten commands wey dey up so.

FAQ

Wetin be the dnf equivalent of apt update?

No command dey wey you must run. dnf dey check how old e cached metadata be before every transaction and e go download fresh copy once e don expire, so dnf install for server wey you never touch for one month still go see current packages. sudo dnf makecache dey and e dey force that download, but e real work na to move the delay go time wey you choose instead of make e happen for your next install. The command wey answer "wetin dey wait me" na dnf check-update, wey map go 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 no get anything wey e go translate go. The RPM equivalent na .repo file for inside /etc/yum.repos.d/ wey hold name, baseurl and 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, go download am put for place. For general extra software, the answer usually na EPEL, wey you go enable with sudo dnf config-manager --set-enabled crb follow by sudo dnf install epel-release.

I fit undo dnf upgrade wey break my server?

Yes, but e get limit. Run sudo dnf history to find the transaction number, sudo dnf history info <id> to see wetin exactly 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 no go get anything to reinstall from. E only dey reverse package changes. Configuration file wey upgrade rewrite, or database wey service migrate for first start, go remain as e be. apt no get any equivalent command at all, only the record for /var/log/apt/history.log.

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. If you type yum install httpd, e go run dnf, so old tutorials mostly still dey work. Write new scripts and documentation with dnf, because the yum name na just for compatibility, and prefer dnf config-manager pass the older yum-config-manager binary.

Why dnf remove want delete plenty packages?

Because dnf dey remove dependencies wey nothing else need as part of the same transaction, while 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 usually correct, but read am before you confirm. If package wey dey the list na one wey you want keep, install am explicitly first so dnf go record am as something wey you want for yourself.

Dis article help you?