Linux Admin

Linux Package Management Errors: apt, dpkg, yum, dnf

Package Management Errors

Package managers are the most-touched admin tool, and their error messages are inconsistent across apt, yum, dnf, and friends. Most failures fall into a few categories: lock contention, missing dependencies, signature/GPG issues, and broken repository state. The ten errors below are what you’ll see on Debian/Ubuntu and RHEL-family servers.

#51 – Could not get lock /var/lib/dpkg/lock

Description: Another apt/dpkg process is running.

Solution: ps aux | grep -E "apt|dpkg" — if a real process, wait. If stale: rm /var/lib/apt/lists/lock /var/lib/dpkg/lock-frontend and retry. Common cause: unattended-upgrades running while you’re trying to install.

#52 – Unmet dependencies

Description: apt or dpkg refuses an install because required packages are missing or unsatisfiable.

Solution: apt --fix-broken install; or dpkg --configure -a; for yum: yum-complete-transaction or dnf shell.

#53 – NO_PUBKEY (GPG signature)

Description: apt update fails because the repo’s signing key isn’t in the local keyring.

Solution: apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEYID; modern Debian: drop the key in /etc/apt/trusted.gpg.d/; then apt update.

#54 – Hash sum mismatch

Description: apt downloads metadata that doesn’t match the expected hash and aborts.

Solution: Mirror is out of sync or local cache is corrupt. apt clean && apt update; or wait for mirror refresh.

#55 – Held broken packages

Description: apt refuses to install or upgrade because some packages are held in a broken state.

Solution: apt-get -f install attempts repair. apt-mark showhold shows held packages; apt-mark unhold pkg to release.

#56 – dpkg: error processing package

Description: A package’s install or upgrade failed mid-transaction, often during the postinst script.

Solution: Run with --debug to see what failed; often a postinst script. Manual: dpkg --remove --force-remove-reinstreq pkg then reinstall.

#57 – Repository unreachable

Description: apt update can’t fetch from a configured mirror.

Solution: curl http://archive.ubuntu.com/... — can you reach it? DNS, proxy, firewall? Edit /etc/apt/sources.list; for corporate environments, set Acquire::http::Proxy in /etc/apt/apt.conf.d/.

#58 – Insufficient disk space (during install)

Description: Package manager aborts because /var or /usr ran out of space mid-install.

Solution: apt clean, journalctl --vacuum-size=500M, remove old kernels (apt autoremove --purge), check /var/cache.

#59 – GPG error: signing key has expired

Description: apt update fails because the repo’s signing key has expired.

Solution: Update keyring package (apt install ubuntu-keyring); or manually fetch new key from project site.

#60 – Conflict with another package

Description: Install fails because two packages claim ownership of the same file or feature.

Solution: apt remove conflicting-package first, or use apt install --no-install-recommends to limit deps. Don’t use --force-overwrite unless you understand the consequence.

Conclusion

Five habits:

  1. apt update before any install — cached metadata is the source of half of all package errors.
  2. If a transaction fails partway: dpkg --configure -a on Debian, yum-complete-transaction on RHEL.
  3. Disable unattended-upgrades before manual maintenance to avoid lock contention.
  4. Pin keyring updates separately so signing keys don’t expire under you.
  5. Don’t mix package sources (Debian + Ubuntu, two PPAs with the same package) — conflicts come from upstream not from your config.