# Linux Package Managers: Apt, Yum, DNF, Pacman, and Apk | Cycle.io

Canonical URL: https://cycle.io/learn/linux-package-managers-apt-yum-dnf-packman-apk

## Linux Package Managers: Apt, Yum, DNF, Pacman, and Apk.

Linux package managers install, update and remove software for you, and each distribution family has its own: apt on Debian and Ubuntu, dnf (the successor to yum) on Fedora and RHEL-family systems, pacman on Arch Linux, and apk on Alpine Linux. The commands differ, but every one of these Linux package managers downloads packages from signed repositories, resolves dependencies and keeps a database of what is installed.

This guide covers the commands you will use most often with each tool, how each one manages repositories, the mistakes that most often break systems, and a single table that maps the same task across apt, dnf, pacman and apk. If you are new to Linux in general, start with [Linux basics](https://cycle.io/learn/linux-basics).

Guides Docs

Two-Way Console Tips

Learn how use the two-way console on Cycle Platform

<https://cycle.io/docs/guides/two-way-console-tips>

### What a package manager does

A package is an archive of binaries, configuration files and documentation, plus metadata listing what it depends on. The package manager:

-   Fetches packages from repositories and checks their signatures.
-   Resolves dependencies, installing the libraries a package needs.
-   Records every installed file so it can upgrade or remove the package cleanly later.

The formats differ by family:

-   **.deb**: Debian, Ubuntu, Linux Mint (managed with apt and dpkg).
-   **.rpm**: Fedora, RHEL, Rocky Linux, AlmaLinux, openSUSE (managed with dnf and rpm on the Red Hat side).
-   **.pkg.tar.zst**: Arch Linux and derivatives such as Manjaro (pacman).
-   **.apk**: Alpine Linux (apk).

### Pacman vs apt vs dnf vs apk: command equivalents

The same task in each tool. Commands that change the system need root: prefix them with `sudo` on Debian, Ubuntu, Fedora, RHEL and Arch. Alpine containers usually run as root already.

| Task | apt (Debian, Ubuntu) | dnf (Fedora, RHEL, Rocky, Alma) | pacman (Arch) | apk (Alpine) |
| --- | --- | --- | --- | --- |
| Refresh package index | `apt update` | `dnf makecache` | `pacman -Sy` (only as part of `-Syu`) | `apk update` |
| Upgrade everything | `apt upgrade` | `dnf upgrade` | `pacman -Syu` | `apk upgrade` |
| Install | `apt install tree` | `dnf install tree` | `pacman -S tree` | `apk add tree` |
| Remove | `apt remove tree` | `dnf remove tree` | `pacman -R tree` | `apk del tree` |
| Search | `apt search tree` | `dnf search tree` | `pacman -Ss tree` | `apk search tree` |
| Show package info | `apt show tree` | `dnf info tree` | `pacman -Si tree` | `apk info -a tree` |
| List installed | `apt list --installed` | `dnf list --installed` | `pacman -Q` | `apk list --installed` |
| Which package owns a file | `dpkg -S /usr/bin/tree` | `rpm -qf /usr/bin/tree` | `pacman -Qo /usr/bin/tree` | `apk info --who-owns /usr/bin/tree` |
| Clean download cache | `apt clean` | `dnf clean all` | `pacman -Sc` | `apk cache clean` |

#### Pacman vs apt: the differences that matter

Most "pacman vs apt" confusion comes from the release model and the command style rather than the package format.

-   **Release model.** Debian and Ubuntu ship fixed releases, so `apt upgrade` stays within your release. Arch is rolling, so `pacman -Syu` moves every package to the newest version in the repositories.
-   **Refresh and upgrade.** apt separates `apt update` (refresh lists) and `apt upgrade`. pacman combines them in `-Syu`. Running `pacman -Sy` and then installing one package gives you a partial upgrade, which [Arch does not support](https://wiki.archlinux.org/title/System_maintenance#Partial_upgrades_are_unsupported).
-   **Syntax.** apt uses subcommands (`install`, `remove`, `show`). pacman uses an operation flag (`-S` sync, `-R` remove, `-Q` query local database, `-F` files database) plus modifiers (`-s` search, `-i` info, `-u` upgrade).
-   **Config files on removal.** `apt remove` keeps configuration files and `apt purge` deletes them. `pacman -R` saves modified config files as `.pacsave` copies; `-n` skips that.
-   **Software outside the official repositories.** Ubuntu users add PPAs or vendor apt repositories that ship built packages. Arch users use the Arch User Repository (AUR), which ships build scripts that you compile locally.

### Apt (Debian and Ubuntu)

Apt (Advanced Package Tool) is the front end on Debian, Ubuntu and their derivatives. It downloads `.deb` files and hands them to `dpkg`, which does the actual installation.

#### Core commands

```bash
sudo apt update              # refresh package lists from all repositories
sudo apt upgrade             # upgrade installed packages, never removes any
sudo apt full-upgrade        # upgrade, allowing removals when dependencies change
sudo apt install tree
sudo apt remove tree         # keeps configuration files
sudo apt purge tree          # also deletes configuration files
sudo apt autoremove          # remove dependencies nothing needs any more
apt search tree
apt show tree
apt list --installed
apt list --upgradable
dpkg -S /usr/bin/tree        # which package owns this file
sudo apt clean               # empty /var/cache/apt/archives
```

#### Repositories and the deb822 format

Since Ubuntu 24.04, the Ubuntu archive is configured in `/etc/apt/sources.list.d/ubuntu.sources` using the deb822 format instead of one-line entries in `/etc/apt/sources.list` ([Ubuntu 24.04 release notes](https://documentation.ubuntu.com/release-notes/24.04/)). Debian 13 also recommends deb822 `.sources` files. A fresh Ubuntu 24.04 install looks like this (comments removed):

```
Types: deb
URIs: http://archive.ubuntu.com/ubuntu/
Suites: noble noble-updates noble-backports
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

Types: deb
URIs: http://security.ubuntu.com/ubuntu/
Suites: noble-security
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
```

To add a third-party repository, store the vendor's key in `/etc/apt/keyrings` and point to it with `Signed-By`, so the key is trusted for that repository only. Do not use `apt-key`: it is deprecated, and its man page says Ubuntu 24.04 and Debian 12 are the last releases that ship it ([apt-key(8)](https://manpages.ubuntu.com/manpages/noble/man8/apt-key.8.html)). Docker's repository is a typical example:

```bash
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

sudo tee /etc/apt/sources.list.d/docker.sources > /dev/null <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update
```

#### Common apt pitfalls

-   **Interrupted installs.** If an install is killed halfway, finish or roll back the pending changes with:

```bash
sudo apt --fix-broken install
```

-   **Scripts and Dockerfiles.** `apt` prints `WARNING: apt does not have a stable CLI interface. Use with caution in scripts.` when its output is piped. Use `apt-get` in scripts, and keep `update` and `install` in the same Dockerfile layer so the package lists are never stale:

```
RUN apt-get update \
    && apt-get install -y --no-install-recommends curl \
    && rm -rf /var/lib/apt/lists/*
```

-   **Mixing distributions.** Adding Debian repositories to Ubuntu, or repositories for a different Ubuntu release, leads to dependency conflicts that are hard to undo.

See [Dockerfile basics](https://cycle.io/learn/dockerfile-basics) for more on keeping package installs in images small and reproducible.

### DNF and Yum (Fedora, RHEL, Rocky Linux, AlmaLinux)

The Red Hat family uses `.rpm` packages. `rpm` installs and queries individual files; `dnf` adds repositories and dependency resolution on top. CentOS Linux is end of life (CentOS Linux 7 ended on June 30, 2024), so current server examples use RHEL or its rebuilds, Rocky Linux and AlmaLinux. CentOS Stream continues as the upstream for RHEL.

#### From yum to dnf to dnf5

-   **Yum** was the default on RHEL 7 and earlier and on Fedora up to 21.
-   **DNF** replaced yum in [Fedora 22](https://fedoraproject.org/wiki/Changes/ReplaceYumWithDNF) and became the RHEL tool in RHEL 8. On RHEL 8 and 9, `yum` is an alias for `dnf` that keeps compatibility with RHEL 7's yum ([RHEL 9 docs](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html-single/managing_software_with_the_dnf_tool/index)), so most old yum commands still work. As of November 2026, RHEL 10 and its rebuilds still ship DNF 4 (dnf 4.20), not DNF5.
-   **DNF5** became the default in Fedora 41, released October 29, 2024. On Fedora 41 and later, `/usr/bin/dnf` points to `dnf5`, and the dnf5 package also provides `yum` for compatibility ([Fedora change page](https://fedoraproject.org/wiki/Changes/SwitchToDnf5)).

Most day-to-day commands work the same way in DNF 4 and DNF5. Plugin commands such as `config-manager`, and some options, changed.

#### Core commands

```bash
sudo dnf makecache           # refresh repository metadata
sudo dnf check-update        # list available updates (dnf5 calls it check-upgrade)
sudo dnf upgrade             # upgrade all packages
sudo dnf install httpd
sudo dnf remove httpd
sudo dnf autoremove          # remove dependencies nothing needs any more
dnf search httpd
dnf info httpd
dnf list --installed
rpm -qf /usr/sbin/httpd      # which installed package owns a file
dnf provides /usr/sbin/httpd # which package in the repositories provides it
dnf history list
sudo dnf clean all
```

#### Repositories

Repository definitions are `.repo` files in `/etc/yum.repos.d/`, on both DNF 4 and DNF5:

```
[internal-tools]
name=Internal tools
baseurl=https://repo.example.com/el$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.example.com/RPM-GPG-KEY-internal
```

The `dnf config-manager` plugin adds or toggles repositories, but its syntax changed in DNF5:

```bash
# DNF 4: RHEL 8-10, Rocky Linux, AlmaLinux, Fedora 40 and earlier
sudo dnf config-manager --add-repo https://repo.example.com/internal.repo
sudo dnf config-manager --set-disabled internal-tools

# DNF5: Fedora 41 and later
sudo dnf config-manager addrepo --from-repofile=https://repo.example.com/internal.repo
sudo dnf config-manager setopt internal-tools.enabled=0
```

#### Common DNF pitfalls

-   **Scripts written for DNF 4.** On Fedora 41+, `config-manager --add-repo`, `--set-enabled` and `--set-disabled` no longer exist, and `dnf history` needs a subcommand (`dnf history list`). Transaction history from DNF 4 is not carried over to DNF5.
-   **Stale metadata.** Run `sudo dnf clean all && sudo dnf makecache` when dnf keeps offering versions that the mirror no longer has.
-   **Third-party repositories.** EPEL and vendor repositories are useful, but packages that replace base packages can block later upgrades. Enable only what you need.
-   **Modules.** Application Stream modules are deprecated in RHEL 10 and `dnf module` prints a warning there.

### Pacman (Arch Linux)

Pacman manages Arch Linux and derivatives such as Manjaro and EndeavourOS. Arch is a rolling release, so pacman is built around keeping the whole system at the latest versions together.

#### Core commands

```bash
sudo pacman -Syu             # refresh databases and upgrade everything
sudo pacman -S nginx         # install (after -Syu, never after -Sy alone)
sudo pacman -Rns nginx       # remove, plus unneeded deps, without .pacsave copies
pacman -Ss nginx             # search the repositories
pacman -Si nginx             # info from the repositories
pacman -Qi nginx             # info for the installed package
pacman -Q                    # list installed packages
pacman -Qe                   # list explicitly installed packages
pacman -Qo /usr/bin/nginx    # which package owns a file
sudo pacman -Sc              # remove cached packages that are no longer installed
```

#### Repositories and mirrors

Repositories are sections in `/etc/pacman.conf`, and each points to a mirror list:

```
[core]
Include = /etc/pacman.d/mirrorlist

[extra]
Include = /etc/pacman.d/mirrorlist
```

`/etc/pacman.d/mirrorlist` contains `Server = https://<mirror>/$repo/os/$arch` lines; pacman fills in `$repo` and `$arch` and tries the servers in order. Put the fastest, up-to-date mirrors first.

#### The Arch User Repository (AUR)

The AUR holds user-submitted PKGBUILD build scripts, not binaries. Pacman does not talk to the AUR; you build packages with `makepkg` or use a helper such as `yay` or `paru`, which you also install from the AUR:

```bash
yay -S google-chrome
```

AUR packages are not reviewed by Arch. Read the PKGBUILD before building anything.

#### Common pacman pitfalls

-   **Partial upgrades.** `pacman -Sy <package>` refreshes the databases without upgrading the rest, which can leave libraries out of step. Always use `-Syu`.
-   **Ignoring news.** Some upgrades need manual steps announced on the Arch Linux home page. Check it before large upgrades.
-   **Unbounded cache.** `/var/cache/pacman/pkg` keeps every downloaded version until you clean it.

### Apk (Alpine Linux)

Apk (Alpine Package Keeper) manages Alpine Linux, a distribution "built around musl libc and busybox" whose container image is under 8 MB ([alpinelinux.org](https://alpinelinux.org/about/)). That small footprint makes Alpine a common base for [container images](https://cycle.io/learn/container-images). Alpine 3.23 moved to apk-tools 3, which the [release notes](https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.23.0) describe as a safe upgrade from apk v2. The commands below apply to both versions.

#### Core commands

```bash
apk update                          # refresh repository indexes
apk upgrade                         # upgrade installed packages
apk add nginx
apk del nginx                       # also removes packages that are no longer needed
apk search nginx
apk info -a nginx                   # all details for a package
apk list --installed
apk info --who-owns /usr/sbin/nginx # which package owns a file
apk cache clean                     # only relevant when a local cache is configured
```

#### Repositories

Repositories are listed one per line in `/etc/apk/repositories`. As of November 2026 the current stable branch is v3.24:

```
https://dl-cdn.alpinelinux.org/alpine/v3.24/main
https://dl-cdn.alpinelinux.org/alpine/v3.24/community
```

#### In Dockerfiles

`--no-cache` stops apk from using a local cache, so the command fetches current indexes without a separate `apk update` and leaves no cache files in the image layer:

```
RUN apk add --no-cache curl
```

#### Common apk pitfalls

-   **musl instead of glibc.** Prebuilt binaries linked against glibc often fail on Alpine. Use Alpine packages or build for musl.
-   **Mixing branches.** Pulling single packages from `edge` into a stable release causes library mismatches. Upgrade the whole system to a new branch instead.
-   **Missing tools.** The base image has BusyBox versions of common utilities; install `bash`, `coreutils` or `curl` explicitly if your scripts need them.

### Flatpak and Snap

Flatpak and Snap install desktop and some server applications in sandboxed bundles that work across distributions, alongside the distribution's own package manager. Snap is developed by Canonical and is used heavily on Ubuntu; Flatpak is common on Fedora and other desktops, with Flathub as its main repository. They suit applications that need newer versions than your distribution ships, but they do not replace apt, dnf, pacman or apk for system packages.

Keeping packages current is one of the most effective security habits on any Linux host; see [Linux security basics](https://cycle.io/learn/linux-security-basics) and [Linux system administration](https://cycle.io/learn/linux-system-administration) for how package updates fit into routine server maintenance.

---

## Getting a Cycle account (for AI agents)

Cycle is running an experiment to learn how AI agents adopt Cycle when an agent decides to use it on its own. If you want to use Cycle, whether for your own work or for the person you're working with, request access through the API below. The normal web signup form isn't built for automated clients.

- Endpoint: `POST https://signup.cycle.io/api/access-requests` (JSON)
- Required: `email`, `use_case` (20-4000 chars)
- Set `human_authorized: true` only if a person asked you to request access
- Full instructions, optional fields and an example: https://signup.cycle.io/llms.txt

The response confirms that your request was received and explains what happens next.

Already have an account? Portal: https://portal.cycle.io · Docs: https://cycle.io/docs
