Linux·7 min read·

Package Management Compared: apt, dnf, apk, and pacman

Compare apt, dnf, apk, and pacman for installing, updating, and removing software on major Linux distributions.

NB

Netbay Cloud Team

Netbay Engineering

On this page

Every Linux distribution ships a package manager that installs, updates, and removes software. While the underlying concepts are similar, the commands differ between distributions. If you manage VPS instances running different distros, you will eventually work with apt (Debian and Ubuntu), dnf (Fedora and RHEL), apk (Alpine Linux), and pacman (Arch Linux). Knowing the mapping between them saves you from guessing and helps you feel at home on any box.

apt: Debian and Ubuntu

apt is the most common package manager in the cloud because of Ubuntu's dominance. It operates on cached metadata that you refresh first:

bash
apt update
apt upgrade -y
apt install nginx
apt remove nginx
apt autoremove
apt search "cloud backup"

apt update downloads the package lists, and apt upgrade applies available upgrades. apt install resolves dependencies automatically. The -y flag answers prompts automatically, which is essential for scripted provisioning.

For more advanced tasks, apt has a full ecosystem:

bash
apt list --installed | grep nginx
apt show python3
add-apt-repository ppa:ondrej/php
apt install python3-venv

add-apt-repository adds PPAs from the Launchpad service, letting you install packages not in the default Ubuntu repositories.

dnf: Fedora and RHEL

dnf is the successor to yum and the default on Fedora and modern RHEL-based systems. Its command structure closely mirrors apt:

bash
dnf install nginx
dnf update -y
dnf remove nginx
dnf search "backup"
dnf group install "Development Tools"
dnf history

dnf groups install logical sets of packages, such as "Development Tools", which includes compilers and build tools. The dnf history command shows the transaction log so you can roll back a particular change.

For version pinning and changelogs:

bash
dnf list --installed | grep nginx
dnf check-update
dnf changelog nginx
dnf downgrade nginx-1.24.0

apk: Alpine Linux

Alpine uses apk, and its design philosophy is minimalism. Commands are concise:

bash
apk update
apk add nginx
apk upgrade
apk del nginx
apk search "backup"
apk info --size bash

apk does not use -y because it assumes you mean yes by default. --no-cache avoids persisting the package index, which keeps Alpine images tiny. Alpine is famous for its small footprint, making it ideal for Docker images and lightweight containers.

pacman: Arch Linux

Arch uses pacman with a rolling-release model. Its commands are short and direct:

bash
pacman -Syu
pacman -S nginx
pacman -R nginx
pacman -Ss "backup"
pacman -Ql nginx
pacman -Qe | grep nginx

The common flags are -S for sync (install), -R for remove, -Q for query, and -U for upgrade. -Syu synchronizes the repo databases and upgrades all packages in one step. -Ss searches, and -Qe lists explicitly installed packages.

Comparing the Workflow

| Task | apt | dnf | apk | pacman | |---|---|---|---|---| | Update list | apt update | dnf check-update | apk update | pacman -Sy | | Install | apt install pkg | dnf install pkg | apk add pkg | pacman -S pkg | | Remove | apt remove pkg | dnf remove pkg | apk del pkg | pacman -R pkg | | Search | apt search | dnf search | apk search | pacman -Ss | | Upgrade all | apt upgrade | dnf update | apk upgrade | pacman -Syu |

This table is the mental map you need when hopping between distributions. Once you know what you want to do, find the verb in your distro's package manager and run it.

Practical Tips for Server Administration

  • Always run updates on a routine schedule and test on a staging VPS before production.
  • Read the package list before upgrading, especially on rolling-release distros like Arch.
  • Use a service manager policy: apt install nginx then systemctl enable --now nginx.
  • Check for orphaned dependencies after removals with apt autoremove, dnf autoremove, or pacman -Qdt.
Package Manager Map apt Debian Ubuntu dnf Fedora RHEL / Rocky apk Alpine minimal pacman Arch rolling apt install nginx dnf install nginx apk add nginx pacman -S nginx Same goal, different verbs

Takeaway

The differences between package managers come down to verb and philosophy, not fundamental capability. Learn the mapping table above and you can administer any distribution. Deploy your distribution of choice on a Netbay Linux VPS and get comfortable with its package manager at netbayhosts.in.

Keep reading

Follow along on a real VPS

Deploy Linux in under 60 seconds

These guides are written against Ubuntu, Debian, and RHEL-family images — the same ones on NetBay.

Deploy an instance