Linux / Intermediate: system administration reasoning / Lesson 8
Manage software through package metadata
Understand repository trust, dependency transactions, and distribution-specific package tools before changing installed software.
On this page
Lesson goals
- Distinguish package metadata from installed packages.
- Compare Debian-family and RPM-family workflows.
- Plan upgrades with configuration and recovery in mind.
Packages describe more than files
A package bundles files with identity, version, dependency information, and often lifecycle scripts. The package database records what the manager believes is installed. Repository metadata describes available versions and relationships. Refreshing metadata does not itself install every upgrade, and searching available packages does not prove a package is installed. Distribution release and architecture determine which builds are compatible. Record /etc/os-release and tool versions before following instructions. Package names can differ across distributions even when they provide an executable with the same familiar name.
Inspect first with the native tools
On Debian-family systems, dpkg-query inspects installed package records and apt-cache inspects APT metadata. apt is designed for interactive use, while apt-get and apt-cache offer more suitable interfaces for scripts that rely on stable behavior. On RPM-family systems, rpm queries the installed database and a supported DNF implementation handles repository transactions. DNF4 and DNF5 command details and defaults can differ, so use the local manual. Querying a package is distinct from installing, upgrading, or removing it; begin investigations with read-only queries.
dpkg-query -W -f='${Package} ${Version}\n' bash
apt-cache policy bash
These read-only queries show the installed Bash record and APT’s version candidates on a compatible lab image. Versions and origins depend on that image; no fixed output is asserted.
Repository trust is a supply-chain choice
A signed repository helps authenticate metadata according to the distribution’s trust model; it does not prove that every package is appropriate for your system. Adding a third-party repository expands who may supply executable code, including privileged package scripts. Prefer the distribution’s documented sources, inspect key scope and origin, and avoid mixing unrelated release repositories. A downloaded installation script piped straight into a shell hides both the reviewed content and the dependency plan. When an application needs another delivery format, evaluate its update and trust mechanism explicitly.
Read the proposed transaction
An upgrade can install dependencies, replace libraries, trigger service actions, or ask how to handle modified configuration files. Read the whole proposed transaction rather than approving only the target package name. apt-get -s simulates a plan without applying package changes, although it still relies on local metadata and cannot guarantee the eventual transaction will be identical. Repository state may change before a real installation. Removal and purge have different configuration consequences in Debian tooling. Never manually delete package database entries to force a broken transaction to disappear.
apt-get -s install bash
rpm -q bash
The first line belongs to a Debian-family lab; the second belongs to an RPM-family lab. They are alternatives for study, not a combined installation recipe, and neither applies an upgrade.
Plan recovery and verify the application
Before an important upgrade, preserve configuration, identify service impact, and confirm a recovery method appropriate to that application’s data format. Downgrading a binary does not necessarily reverse a database migration. Afterward check both package-manager status and the application’s real behavior. Record version, origin, and configuration decisions so another administrator can reproduce the result. Security updates should be assessed through the distribution’s supported advisory process, including backported fixes: an older-looking upstream version string can still contain the distribution’s security patch.
Common errors and fixes
Package not found after changing sources
- Why it happens
- Metadata is stale, the name differs, or the release lacks that package.
- How to fix it
- Check release, configured sources, and the documented package name.
- Prevent it next time
- Use distribution-specific instructions and metadata checks.
Mixing release repositories
- Why it happens
- A newer package was sought without reviewing dependencies.
- How to fix it
- Return to a supported coherent source configuration in the lab.
- Prevent it next time
- Treat repository changes as system-wide changes.
Assuming package success means service health
- Why it happens
- Only transaction completion was verified.
- How to fix it
- Check the application and its logs after the planned change.
- Prevent it next time
- Define functional verification before upgrading.
Check your understanding
1. Why should metadata refresh and software upgrade be separate concepts?
Show worked solution
Refresh updates knowledge of available versions; upgrade changes installed software through a dependency transaction. Separating them helps explain stale search results and permits reviewing a change plan before applying it. Both depend on the configured release sources and trust settings.
2. A vendor requests a new repository for one utility. What evidence should you gather?
Show worked solution
Identify supported distribution releases, signing and key scope, package origin, dependencies, lifecycle scripts, update support, and a removal or recovery plan. Inspect a simulated transaction on a disposable matching image. A familiar utility name is insufficient evidence of compatibility.
Key takeaways
- Use native metadata and inspect transactions before mutation.
- Repository trust, service health, and recovery are separate checks.