Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

APT

Direct answer

APT (apt, apt-get, apt-cache) downloads packages from repositories, resolves dependencies and calls dpkg to install them.

When to use this

Use it to install, upgrade or remove packages on Debian/Ubuntu, or when apt reports held or broken packages.

First 30 seconds

1. apt update first.

2. Held or broken → apt-mark showhold, apt -f install.

3. Lock error → ps aux | grep -E 'apt|dpkg' and wait.

4. Simulate: apt -s install <pkg>.

5. History: /var/log/apt/history.log.

Operational verification

apt reads indexes → resolves dependencies → downloads .debs → dpkg installs → triggers run

Evidence · next step

For Package Management → Debian / Ubuntu → APT, continue with the first unproven Topic check: Refresh/inspect metadata deliberately and record source errors rather than hiding them. If that boundary is healthy, advance to the adjacent check: Compare installed and candidate versions plus origin, pin priority, holds and architecture. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it to install, upgrade or remove packages on Debian/Ubuntu, or when apt reports held or broken packages.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

sources/pinning/holds → repository indexes → APT cache/policy → candidate selection → dependency/conflict solver → transaction plan → download/authentication → dpkg operations → package state → workload verification

Healthy evidence: metadata sources are valid, policy selects the intended candidate, the reviewed plan contains expected changes, dpkg completes and affected workloads validate.

Step 2 Verification and output interpretation Verify boundary

Existing fast checks for this Topic. - Refresh/inspect metadata deliberately and record source errors rather than hiding them.

  • Compare installed and candidate versions plus origin, pin priority, holds and architecture.
  • Review the exact transaction plan including removals, new dependencies and upgrades.
  • After execution, verify dpkg state, package version and workload/service acceptance.

Verification chain. sources/pinning/holds → repository indexes → APT cache/policy → candidate selection → dependency/conflict solver → transaction plan → download/authentication → dpkg operations → package state → workload verification

Step 3 Commands Verify boundary
apt update
apt install nginx
apt policy nginx
apt-mark hold nginx
Step 4 Failure modes and next checks Narrow the fault

Suspicious evidence: stale cache, pin/hold/phased-update policy or solver removals are missed because only the final apt command output is inspected.

Step 5 Common mistakes Narrow the fault
  • apt upgrade vs full-upgrade differences ignored.
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points

apt-mark showhold lists held packages. "Could not get lock" means another apt (often unattended-upgrades) is running — wait, don't delete the lock. Use apt -s to simulate.

Key checks
  • dpkg --audit — half-installed or unconfigured packages
  • apt policy <pkg> / dnf info <pkg> — installed and candidate versions
  • dpkg -l <pkg> / rpm -q <pkg> — installed package
  • apt-cache depends <pkg> / dnf repoquery --requires <pkg> — dependencies
  • dpkg -S <file> / rpm -qf <file> — package owning a file
ReferenceWhat it is1 section · depth on demand

Core model

Treat APT as a policy and orchestration layer. Show source-list configuration and metadata freshness, then inspect candidate versions and pin priorities before accepting the solver plan. Distinguish update from upgrade/install, simulation/plan from execution, and APT completion from downstream dpkg configuration and workload health. Holds, phased updates, architecture qualifiers and repository priority can explain unexpected candidates.

ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

APT shows repository policy, candidate selection and orchestration only to the observed point; local dpkg success and workload state remain separate things to check.

In depth

APT: upgrade, full-upgrade and removal

APT installs packages from repositories and resolves dependencies. The apt(8) manual page explains the distinctions that matter most:

  • update downloads package lists, and every other command depends on them.
  • upgrade installs newer versions, but never removes packages. An upgrade that would require removing something is held back.
  • full-upgrade may remove packages when that's needed to upgrade the system as a whole.
  • remove leaves small configuration files behind, and purge removes those too.
  • autoremove removes automatically installed dependencies that nothing needs any more. Packages you installed explicitly are never proposed.
  • pkg=version or pkg/release selects a specific version or release.

Commands

TaskCommand
Refresh listsapt update
Safe upgradeapt upgrade
Upgrade, including new dependencies and removalsapt full-upgrade
Install a specific versionapt install nginx=1.24.0-2ubuntu7
Install from a specific release (e.g. backports)apt install -t bookworm-backports pkg or pkg/bookworm-backports
Show installed and candidate versionsapt policy nginx
List upgradableapt list --upgradable
Hold a package at its versionapt-mark hold pkg
Mark as manually installedapt-mark manual pkg

apt or apt-get

ContextUse
Interactive workapt (progress bars, colours)
Scripts, Ansible, Dockerfilesapt-get / apt-cache (a stable interface)
Non-interactive installsDEBIAN_FRONTEND=noninteractive apt-get -y install ...

"The following packages have been kept back"

This message means upgrade refused to install a package, because doing so would need new dependencies or removals. Run full-upgrade after reviewing what it would do. Phased updates on Ubuntu can also hold packages back temporarily, which is intended behaviour.

host$ sudo apt update
host$ apt list --upgradable 2>/dev/null | wc -l
14
host$ sudo apt upgrade
The following packages have been kept back:
  linux-generic linux-headers-generic linux-image-generic
host$ sudo apt full-upgrade --dry-run | grep -E "^(Inst|Remv)" | head
host$ apt policy nginx
nginx:
  Installed: 1.24.0-2ubuntu7
  Candidate: 1.24.0-2ubuntu7.1
host$ sudo apt-mark hold postgresql-16 && apt-mark showhold
host$ sudo apt autoremove --purge

Reading the example

The kernel metapackages were kept back because they pull in new kernel packages. full-upgrade --dry-run shows the planned installs and removals first. A held package, here postgresql-16, stays at its current version until it's released with apt-mark unhold.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

APT is part of Package Management → Debian / Ubuntu → APT. APT is Debian-family repository-aware package management: it downloads repository indexes, computes candidates using version/pinning rules, resolves dependencies/conflicts and orchestrates dpkg transactions for install, upgrade and removal operations.

Topic-specific state model. APT is Debian-family repository-aware package management: it downloads repository indexes, computes candidates using version/pinning rules, resolves dependencies/conflicts and orchestrates dpkg transactions for install, upgrade and removal operations.

Interpretation rule. - apt update success ≠ packages upgraded.

  • Candidate version ≠ installed version.
  • Solver plan ≠ committed dpkg transaction.
  • APT exit 0 ≠ application acceptance test passed.

Quick reference

APT details:

apt policy nginx                         # candidate version and pin priorities
apt-cache depends nginx; apt-cache rdepends nginx
apt install nginx=1.24.0-2ubuntu7         # specific version
apt autoremove --purge
apt-get -s upgrade                        # simulate
apt-get -o Dpkg::Options::='--force-confold' -y upgrade   # keep local configs (automation)
cat /var/log/apt/history.log

Pinning (/etc/apt/preferences.d/) controls which repository wins. Lock errors (/var/lib/dpkg/lock-frontend) usually mean unattended-upgrades is running — wait rather than deleting locks.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. APT shows repository policy, candidate selection and orchestration only to the observed point; local dpkg success and workload state remain separate things to check.

ReferenceConfiguration & state1 section · depth on demand

Configuration, persistence and lifecycle

Distribution/platform context. APT owns Debian-family repository policy, candidate/dependency solving and dpkg orchestration. dpkg command semantics remain an existing Command leaf; repository trust/config lives in Debian/Ubuntu Repositories.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in Package Management → Debian / Ubuntu → APT. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://www.debian.org/doc/manuals/debian-reference/ch02.en.html · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
apt linuxadvanced package toolapt dependency resolverapt candidate version
Embedded reference data

Quick lookup tables

APT operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for APT.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateAPT is Debian-family repository-aware package management: it downloads repository indexes, computes candidates using version/pinning rules, resolves dependencies/conflicts and orchestrates dpkg transactions for install, upgrade and removal operations.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin host + distribution/release + architecture → identify exact package/version request → enumerate effective repositories/trust → refresh/inspect metadata → compare installed versus candidate/origin → review dependency/conflict transaction → capture package-manager transaction → verify local package database/files/scripts → inspect service/reboot/config effects → repeat original workload test.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chainsources/pinning/holds → repository indexes → APT cache/policy → candidate selection → dependency/conflict solver → transaction plan → download/authentication → dpkg operations → package state → workload verificationTrace requested/configured state through effective state to the observed workload result.
Failure boundaryAPT proves repository policy, candidate selection and orchestration only to the observed point; local dpkg success and workload state remain separate boundaries.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated Linux package-management evidence can establish this proof path: sources/pinning/holds → repository indexes → APT cache/policy → candidate selection → dependency/conflict solver → transaction plan → download/authentication → dpkg operations → package state → workload verificationUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove behavior outside the captured repository, solver, transaction, local package database, runtime-side-effect or workload scope. APT proves repository policy, candidate selection and orchestration only to the observed point; local dpkg success and workload state remain separate boundaries.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven boundary: confirm distribution/release and repository trust, inspect candidate/origin and solver policy, correlate the package-manager transaction with dpkg/RPM local state, then test affected services and the original workload before making additional package changes.Continue to the next unresolved boundary while preserving the original test condition.

APT · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundaryAPT
Topic pathPackage Management → Debian / Ubuntu → APT
Runtime stateAPT is Debian-family repository-aware package management: it downloads repository indexes, computes candidates using version/pinning rules, resolves dependencies/conflicts and orchestrates dpkg transactions for install, upgrade and removal operations.
Fast checks- Refresh/inspect metadata deliberately and record source errors rather than hiding them. - Compare installed and candidate versions plus origin, pin priority, holds and architecture. - Review the exact transaction plan including removals, new dependencies and upgrades. - After execution, verify dpkg state, package version and workload/service acceptance.
Verification chainsources/pinning/holds → repository indexes → APT cache/policy → candidate selection → dependency/conflict solver → transaction plan → download/authentication → dpkg operations → package state → workload verification Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary.
Failure boundaryAPT proves repository policy, candidate selection and orchestration only to the observed point; local dpkg success and workload state remain separate boundaries. Boundary chain: repository/metadata → dependency resolution → artifact/signature → package database/file install → scriptlets → service/process reload → effective binary/config → workload.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?