✦ For everyone, free.

Practical knowledge for real and everyday life

Home

Package Querying and System Inspection

Package Querying and System Inspection identifies and analyzes software packages and system components in Linux to ensure stability and security.

Package Querying and System Inspection encompasses the methods and tools used to obtain detailed information about software packages installed on or available to a Linux system. It involves querying package databases and repositories to inspect package metadata, versions, dependencies, files, and their origins, as well as verifying the integrity and installation status of packages. This process is essential for system administrators and users to maintain, troubleshoot, and optimize software environments by understanding package relationships and ensuring system consistency.


Package Search

Searching Installed Packages

Locating packages already installed on a system can be done through various package manager commands. This helps identify what software is present and check specific package attributes.

Example with dpkg on Debian-based systems:

dpkg -l | grep <package-name>

Example with rpm on Red Hat-based systems:

rpm -qa | grep <package-name>

Package managers also provide direct search commands to locate installed packages matching a pattern.

Searching Available Packages

To discover packages available in configured repositories, package managers offer search capabilities that query remote metadata.

For example, apt-cache search lists packages in Debian-based repositories:

apt-cache search <keyword>

In RPM-based systems, yum search or dnf search performs similar functions:

dnf search <keyword>

This allows users to explore new software or updates beyond what is currently installed.


Package Information Queries

Viewing Package Metadata

Detailed metadata for a package includes description, version, maintainer, license, and more. This information helps evaluate the suitability of a package.

Examples:

  • Debian-based:
apt show <package-name>
  • RPM-based:
rpm -qi <package-name>

Inspecting Package Versions

Checking the version of installed or available packages is crucial for compatibility and security.

  • List installed package version:
dpkg -s <package-name>

or

rpm -q <package-name>
  • Compare with repository versions using update or info commands.

Installed Package Inventory

Listing All Installed Packages

Obtaining a full inventory of installed packages assists in system audits and backup preparation.

  • Debian-based:
dpkg -l
  • RPM-based:
rpm -qa

Filtering Installed Packages

Filtering by criteria such as name, version, or status facilitates targeted inspections.

Example:

dpkg -l | grep ^ii

lists installed packages only.


Available Package Inventory

Listing All Available Packages

Users can view all packages available from configured repositories to understand the software ecosystem accessible.

  • Debian-based:
apt-cache pkgnames
  • RPM-based:
dnf list available

Repository-Specific Listings

Some package managers support querying specific repositories to see packages maintained by particular sources.


Package Version Inspection

Comparing Installed and Available Versions

Identifying whether installed packages are up to date or have newer versions in repositories is key for maintenance.

  • Debian-based:
apt list --upgradable
  • RPM-based:
dnf check-update

Viewing Detailed Version Information

Commands allow inspection of version numbers, release tags, and build information to assess package provenance.


Repository Origin Inspection

Identifying Package Source Repositories

Determining the repository from which a package was installed helps in validating its trustworthiness and managing repository priorities.

  • Debian-based:
apt-cache policy <package-name>
  • RPM-based:
dnf repoquery --info <package-name>

Managing Repository Metadata

Package managers maintain metadata caches that map packages to repositories; inspecting this data aids troubleshooting.


Package File Listings

Listing Files Installed by a Package

Knowing which files belong to a package assists in audit, cleanup, and conflict resolution.

  • Debian-based:
dpkg -L <package-name>
  • RPM-based:
rpm -ql <package-name>

Searching Which Package Owns a File

Identifying which package installed a particular file helps locate responsible software.

  • Debian-based:
dpkg -S <file-path>
  • RPM-based:
rpm -qf <file-path>

File Ownership Queries

Mapping Files to Packages

This is essential for troubleshooting and verifying system integrity, especially after manual changes.

Package managers provide commands to reverse-map files to their owning packages, aiding in pinpointing software sources.


Dependency Inspection

Viewing Package Dependencies

Understanding package dependencies is critical for installation, updates, and troubleshooting.

  • Debian-based:
apt-cache depends <package-name>
  • RPM-based:
rpm -qR <package-name>

Checking Reverse Dependencies

Finding packages that depend on a particular package supports safe removal and upgrade decisions.


Package Installation Reason Inspection

Determining Why a Package Was Installed

Some package managers track whether a package was explicitly installed by the user or pulled in as a dependency, aiding in cleanup and maintenance.

  • Debian-based:
apt-mark showauto
apt-mark showmanual
  • RPM-based tools may have plugins or logs to reveal installation reasons.

Installed File Verification

Verifying File Integrity of Installed Packages

Checking that package files remain unaltered ensures system security and stability.

  • Debian-based:
debsums <package-name>
  • RPM-based:
rpm -V <package-name>

These commands compare installed files against package metadata to detect corruption or unauthorized changes.


Package Querying and System Inspection is a comprehensive set of practices and commands that provide visibility into package states, origins, contents, and integrity. Mastery of these tools empowers system administrators to maintain reliable, secure, and well-managed Linux environments.

Content in this section