Skip to content
Latchkey

apt-get update: Usage, Options & Common CI Errors

apt-get update downloads the latest package lists so apt knows what is installable.

apt-get update does not install anything - it refreshes the index of available packages. Skipping it is the most common reason a fresh Debian/Ubuntu image cannot find a package that clearly exists.

What it does

apt-get update resynchronizes the local package index from the sources listed in /etc/apt/sources.list and /etc/apt/sources.list.d/. It must run before apt-get install on a fresh image because base images ship with an empty or stale index.

Common usage

Terminal
apt-get update
apt-get update && apt-get install -y curl
apt-get update -o Acquire::Retries=3        # retry flaky mirrors
DEBIAN_FRONTEND=noninteractive apt-get update

Common errors in CI

The signature one bites hardest: "The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 1234ABCD" means a repo's GPG key is missing - import it (gpg --dearmor into /etc/apt/keyrings and reference it with signed-by=) before updating. "Failed to fetch ... 404 Not Found" means a release was moved or the suite name is wrong (e.g. an EOL Ubuntu moved to old-releases.ubuntu.com). "Could not resolve host" is a network/proxy issue in the runner.

Options

FlagWhat it does
-y / --yesAssume yes (used with install, not update)
-o KEY=VALUESet a config option (e.g. Acquire::Retries=3)
-q / -qqQuiet output (good for logs)
--allow-releaseinfo-changeAccept a changed suite/codename

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →