Ubuntu 26.04 Tutorial / Search, Install, and Inspect Packages with APT

Use APT to refresh repository indexes, search, inspect versions, and install Deb packages on Ubuntu. A repository’s candidate version and the version currently installed are different facts; inspect both before and after installation.

Understand apt, apt-get, and dpkg

Tool Main role
apt Interactive searching, installation, and updates
apt-get and apt-cache Installation and query interfaces suited to automation
dpkg and dpkg-query Local package state and ownership of installed files

APT handles repositories and dependencies together, whereas installing a local Deb with dpkg alone may leave dependencies unresolved. Snap and Deb installations are separate package forms even when the application name is the same.

Refresh indexes and inspect origin

sudo apt update
apt search '^hello$'
apt show hello
apt-cache policy hello

The practice package hello prints a short greeting. In apt-cache policy, distinguish Installed, Candidate, and repository origins. Resolve network, signature, or repository errors before relying on stale indexes.

Ubuntu’s package-management guide explains repository indexes and APT operations.

Install and verify execution

sudo apt install hello
LC_ALL=C hello
command -v hello
dpkg-query -S "$(command -v hello)"
apt-cache policy hello

Review proposed additions, upgrades, removals, and space requirements before accepting installation. LC_ALL=C hello provides a consistent greeting language for the exercise. Record execution, installed version, executable path, and owning package separately.

For detailed local status and full inventory queries, see listing installed Ubuntu packages. This exercise focuses on checking origin and verifying a new installation.

When a command or version differs

Package names and executable names do not always match. If installation succeeded but a command is unavailable, inspect installed files with dpkg-query -L hello and compare PATH and packaging type. An absent candidate calls for checking repository components, release support, and the package name.

Do not add an unfamiliar repository merely because it advertises a desired version. Verify 26.04 support, signing keys, and maintenance responsibility first. Review dependency changes when selecting another version.

Clean up and retain a reproducible record

apt-get -s remove hello

If hello was not previously installed and is no longer needed, review the simulation before sudo apt remove hello. Do not remove a previously used package just to clean up a lab. Retain release, repository, version, and execution results for comparison.