Installing software: dnf vs apt
This is the biggest everyday difference between the two families. Once you've got it, you can follow almost any tutorial on either one.
You will learn
- What packages, repositories and package managers are
- Installing, searching, updating and removing software with
dnfand withapt - Why Ubuntu needs
apt updateand why Rocky needs EPEL - Detective work: which package gives me this command, and which package does this file belong to?
The app store idea
On a phone you install apps from an app store. Linux had the same idea years earlier:
- A package is one piece of software, zipped up with instructions for installing it (
.rpmon Rocky,.debon Ubuntu). - A repository (“repo”) is the store: a trusted online collection of thousands of packages, run by the distro.
- The package manager is the store app. It downloads packages, checks they're genuine, and grabs any dependencies (other packages the software needs).
Changing software changes the whole system, so these commands need sudo (lesson 12 explains why).
Install your first package
sudo dnf install tree
dnf refreshes its list of available software by itself. It asks Is this ok [y/N]. The capital N means pressing Enter answers no, so type y.
sudo apt update sudo apt install tree
First apt update refreshes the list of what's available (it doesn't install anything!), then apt install. When apt asks [Y/n], pressing Enter means yes.
Add -y on either one to answer yes automatically: sudo dnf install -y tree or sudo apt install -y tree.
The full comparison
| I want to… | Rocky / RHEL | Ubuntu / Debian |
|---|---|---|
| Refresh the list of available software | automatic (or dnf check-update) | sudo apt update |
| Install something | sudo dnf install NAME | sudo apt install NAME |
| Remove something | sudo dnf remove NAME | sudo apt remove NAME |
| Update everything | sudo dnf upgrade | sudo apt update && sudo apt upgrade |
| Search for software | dnf search WORD | apt search WORD |
| Details about a package | dnf info NAME | apt show NAME |
| List what's installed | dnf list installed or rpm -qa | apt list --installed or dpkg -l |
| See the repositories | dnf repolist | apt policy |
| Old name you'll see in tutorials | yum (still works, it's just dnf) | apt-get (still works) |
| Extra software repo | EPEL: sudo dnf install epel-release | “universe”, already switched on |
Package detective work
Two questions come up constantly: “which package do I install to get the dig command?” and “which package did this file come from?”
| Question | Rocky / RHEL | Ubuntu / Debian |
|---|---|---|
| Which package provides a command? | dnf provides '*/bin/dig' | apt-file search bin/dig (install apt-file), or just run the command: Ubuntu suggests the package |
| Which package owns this file? | rpm -qf /usr/bin/ls | dpkg -S /usr/bin/ls |
| Search (the older tool) | dnf search WORD | apt-cache search WORD |
| Which version would install, and from where? | dnf info NAME | apt-cache policy NAME |
| What does it depend on? | dnf deplist NAME | apt-cache depends NAME |
apt-cache is the older sibling of apt. Scripts and tutorials still use it because its output doesn't change between versions, and apt even warns that its own output isn't meant for scripts.
&& do?A && B means “run A, and if it worked, run B.” That's why sudo apt update && sudo apt upgrade is one of the most-typed lines on Ubuntu.
EPEL: Rocky's bonus shelf
The RHEL family keeps its official repos small and carefully tested. That's great for stability, but some fun or niche tools (like cowsay, htop and sl) aren't in them. They live in EPEL (Extra Packages for Enterprise Linux), a well-known community repo. You switch it on by installing one package:
sudo dnf install epel-release sudo dnf install cowsay
Some EPEL packages also need the CRB repo: sudo dnf config-manager --set-enabled crb
sudo apt install cowsay
Ubuntu's “universe” repo is huge and already switched on, so there's nothing extra to set up.
Sometimes the same program has a different package name in each family. The most famous one: the Apache web server is httpd on Rocky and apache2 on Ubuntu. When an install says “not found,” this is often why. You'll use it in lesson 14.
Try it
Do the missions on one family, then click the other family's button in the terminal bar and do them again. Notice where each one trips you up.
Quick check
1. On Ubuntu, what does sudo apt update do?
✓ Right, and it's the most misunderstood command on Ubuntu. apt upgrade is the one that actually installs updates.
2. sudo dnf install htop says “No match for argument.” What's the most likely fix on Rocky?
✓ htop lives in EPEL. apt doesn't exist on Rocky at all.
3. dnf asks Is this ok [y/N]: and you just press Enter. What happens?
✓ The capital letter is always the default. apt's [Y/n] is the other way around.