Every APT change follows one shape: refresh the index, simulate the change, inspect the plan, then apply it. Held versions, phased rollouts, unattended-upgrade timers, and dpkg locks can silently change what a plain install or upgrade does, so the simulation is what protects you. Use apt interactively and apt-get in scripts, because apt’s output and defaults may change between versions.1

Safe upgrade

  1. sudo apt update refreshes the index only; it upgrades nothing.
  2. apt list --upgradable, then simulate with sudo apt-get -s upgrade (run simulations with sudo so they read the same configuration).
  3. sudo apt upgrade. Use full-upgrade only when adding or removing dependencies is acceptable, after simulating it: it can remove packages.
  4. Verify: nothing left upgradable, dpkg --audit clean, systemctl --failed empty, and check /run/reboot-required.

A major release upgrade is not a package upgrade: use do-release-upgrade with backup and rollback preparation.1

Holds and rollback

apt-mark hold pins a package; record why and when to remove the hold so security updates are not missed indefinitely. To downgrade, confirm the version is still in a configured repository and simulate apt-get -s install <package>=<version>; if it has left the mirror, use a verified repository snapshot (the Ubuntu Snapshot Service, 24.04 and later) or a backup, not an arbitrary old repository.1

Troubleshooting

SymptomCheck firstBoundary
Could not get lockapt-daily timers, unattended-upgrades, APT/dpkg processes, fuser on the lock filesWait; never delete lock files or kill the process
NO_PUBKEY / unsigned repositoryRepository URL, Signed-By, keyring originNo --allow-unauthenticated, no apt-key
404 / Release file expiredCodename, support status, EOLDo not blindly change the codename
dpkg was interrupteddpkg --auditsudo dpkg --configure -a, then sudo apt --fix-broken install
Packages kept back or deferredapt policy, simulationOften phased updates, not a failure; do not force

As listed in the guide. Third-party repositories need a verified owner and signing key stored in /etc/apt/keyrings/ and referenced with Signed-By; Ubuntu 24.04 uses deb822 sources in /etc/apt/sources.list.d/ubuntu.sources.1

Footnotes

  1. Common Ubuntu APT Operations, original ↩ ↩2 ↩3 ↩4