Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

What sudo apt update Does

It contacts every repository configured in /etc/apt/sources.list and the files in /etc/apt/sources.list.d/, downloads their current package lists, and stores them under /var/lib/apt/lists/. After that, apt knows which newer versions exist. It does not install or change any package. To install the updates:

sudo apt update
sudo apt upgrade

The commands are the same on Debian and Ubuntu. Ubuntu 24.04 and later keep the main repository list in ubuntu.sources inside the sources.list.d folder rather than in sources.list.

Read the Output

  • Hit: the list has not changed since the last run.
  • Get: a newer list was downloaded.
  • Ign: an optional file was not found; usually harmless.
  • Err or W: a repository failed; see the errors below.

The last line says how many packages can be upgraded and suggests a command to see them:

apt list --upgradable

update, upgrade, and full-upgrade

CommandWhat it does
apt updateRefreshes package lists only
apt upgradeInstalls newer versions, never removes
apt full-upgradeAlso removes packages when needed
apt autoremoveRemoves dependencies nothing needs

full-upgrade stays within your release; it is not a move to the next Ubuntu version. Before you answer yes, read the list of packages it plans to remove.

Packages Kept Back

When apt says some packages have been kept back, finishing their upgrade needs a step apt upgrade will not take, such as removing a package. On Ubuntu, phased updates also hold some packages back: a new version reaches a growing share of machines over a few days, and yours gets it later. Waiting is the normal answer. For a package kept back for another reason, sudo apt install package upgrades it; read what else it plans to change before you confirm.

Packages you held on purpose are listed by apt-mark showhold. Release one with sudo apt-mark unhold package.

Does the Server Need a Reboot?

A kernel or core library update creates the marker file /var/run/reboot-required. If it exists, a reboot is due:

ls /var/run/reboot-required
cat /var/run/reboot-required.pkgs

The second file lists the packages that asked for it. See how to reboot a Linux server for a safe restart.

A Safe Routine on a Server

  1. Take a snapshot first; see snapshot vs backup.
  2. Run sudo apt update, then apt list --upgradable.
  3. Run sudo apt upgrade and read the summary before confirming.
  4. Run sudo apt autoremove to clear old dependencies.
  5. Reboot if the marker file exists, then check your services with systemctl.

Run long upgrades inside tmux or screen, so a dropped SSH connection does not interrupt them.

Common Errors

  • Missing or expired key: the message names a repository and says its signature cannot be checked, often with NO_PUBKEY or EXPKEYSIG. apt ignores that repository until it has the publisher's current key. Fetch the key the way the publisher documents, or remove the repository file. See add-apt-repository command not found for how keys are stored.
  • Repository does not have a Release file: the repository no longer serves files for your release, typically an old PPA or a release past its end of life. Remove or correct that entry.
  • Could not get lock: another package process is running. See the dpkg lock guide.
  • Temporary failure resolving: the server cannot resolve names. Check DNS and the network with the tools in Linux network commands.
  • Hash sum mismatch: a mirror was being updated while you downloaded. Retry after a few minutes.

apt or apt-get?

Use apt at the terminal: it shows progress and readable summaries. Scripts should call apt-get, whose output format is kept stable. apt-get dist-upgrade is the older name for full-upgrade.

Was this answer helpful?
Loading...