Packages and trusted repositories
Quick answer
A package combines software with metadata that lets the package manager track versions, dependencies and installed files. Start by inspecting the Bash package, without installing anything.
Prepare the practice environment
Use an ordinary user in a disposable VM of the distribution named in the example. For Debian examples use python3 lab-fixtures/packages/setup.py from the extracted package root, enter the printed directory and check pwd; alternatively create a private directory with mktemp -d. Use a fresh directory per example, export LC_ALL=C and Bash with set -o pipefail. Do not use sudo. Keep -s and --no-download on every APT simulation. Skip missing tools; do not install them merely to run an example. On Alpine the simple query also works in a compatible sh. Outputs vary by installed versions and repository state. Stop on unexpected failure.
How it works
A repository is a collection of packages and metadata. APT verifies signed release metadata and uses its checksums to authenticate package indexes and packages. A valid signature establishes provenance under the configured trust policy, not that software is bug-free. Installed records in dpkg are separate from cached repository indexes; a package can be installed even when no downloadable candidate is available. Use official distribution repositories and review third-party signing keys and scope before trusting them. Identify the distribution with cat /etc/os-release first.
Read the installed name and status as two distinct facts: the name identifies a database record, and install ok installed describes its recorded state. Neither checks every installed file. In apt-cache policy, the installed version is the local record and the candidate is the version APT would ordinarily select under its current policy and cached indexes. A candidate field alone does not establish that a package is downloadable or that the cache is current. For an investigation, record both versions and the age of the metadata before deciding whether an update is necessary.
Try the examples
The format prints just the recorded name. Bash must be installed as a Debian package.
Expected stdout:
bashThe three words describe desired action, error flag and current state.
Expected stdout:
install ok installedapt-cache policy bash | grep 'Candidate:' >/dev/null && printf 'candidate field found\n'This checks for a field, not a particular version. Use apt-cache policy bash directly to inspect installed and candidate values; the candidate can be (none).
Expected stdout:
candidate field foundCommon mistakes
Do not disable signature verification or assume an installed package is from the currently configured repository. A checksum without an authenticated source is not proof of origin.
Practice
Inspect bash and coreutils with dpkg-query and apt-cache policy. Explain why the installed version and candidate can differ.
Related references
Study: dpkg-query, apt-cache. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Packages and trusted repositories — Knowledge Check
Apply package-management concepts to the stated distribution and query-only lab.
Which information belongs to an installed package database?
What does signed release metadata help establish?
Which command inspects candidate versions?
Can a package be installed without a current repository download?