6.1 Package Management (RPM/DNF, APT, Zypper), Repositories & Alternatives
Key Takeaways
Query the installed database to identify the package that owns an existing file. Repository-aware managers select available dependencies.
Check enabled repositories, package exclusions and release compatibility before accepting a transaction. Review package removal and upgrade plans.
DNF package signatures and repository metadata verification are separate checks. APT secures the archive through signed release data and checksums.
Follow the source project’s build instructions. Use staging when supported, and check the confinement mode of an application package.
Review intended listeners, basic configuration and verification tools for each common service. System alternatives affect managed links and can be set to manual or automatic mode.
6.1 Package Management (RPM/DNF, APT, Zypper), Repositories & Alternatives
Choose the tool by the task and the distribution. To identify a file that is already installed, query the local package database. To plan an installation or upgrade with dependencies, use the distribution's repository-aware manager and inspect the proposed transaction.
Native packages, queries and transactions
RPM and dpkg inspect archives and installed package records. They can perform package operations and check package dependencies. For missing packages, use DNF, APT or Zypper to select and fetch dependencies from enabled sources. An available archive, a known package in the catalog, and an installed package are different states.
| Task | RPM / DNF 4 on RHEL 9 or compatible host | dpkg / APT on Debian | Zypper on SUSE |
|---|---|---|---|
| Find installed owner of a path | rpm -qf /usr/bin/example | dpkg -S /usr/bin/example | rpm -qf /usr/bin/example |
| Inspect installed files | rpm -ql example | dpkg -L example | rpm -ql example |
| Inspect a local archive | rpm -qpl ./example.rpm | dpkg -c ./example.deb | rpm -qpl ./example.rpm |
| Inspect an available package | dnf info example | apt show example or apt-cache policy example | zypper info example |
| Refresh repository information | dnf makecache | apt update | zypper refresh |
| Install from a repository | dnf install example | apt install example | zypper install example |
| Install a local archive with dependency resolution | dnf install ./example.rpm | apt install ./example.deb | zypper install ./example.rpm |
| Remove an installed package | dnf remove example | apt remove example | zypper remove example |
rpm -ivh installs an RPM with verbose progress, rpm -Uvh upgrades or installs, and rpm -Fvh freshens matching installed packages. rpm -e erases an installed package. dpkg -i installs a local archive but may leave it unconfigured when dependencies are missing. Read the dependency error and inspect the package manager's planned fix. Avoid forcing changes that bypass checks on a managed host.
The RPM verification operation rpm -V openssh-server compares installed files against recorded attributes. For example:
S.5....T. c /etc/ssh/sshd_config
This shows differences in size, digest and modification time for a file marked as configuration. The code 5 is a digest mismatch and does not identify the algorithm. Other flags can identify mode, ownership, symlink target, device numbers or capabilities. A reported difference may be a legitimate local edit. Check package and configuration provenance before replacing the file. To inspect a downloaded RPM's signatures and digests with RPM tooling, use rpmkeys --checksig ./example.rpm and verify the configured trust and result.
On Debian, apt update refreshes metadata. apt upgrade may install a new dependency but holds back upgrades requiring removal of installed packages. apt full-upgrade can remove packages to resolve transitions. apt remove can retain package configuration and apt purge removes package-managed configuration that would otherwise remain. Data or settings in a home directory can remain. Use apt autoremove after reviewing the proposed unused dependencies.
On RHEL 9, dnf upgrade updates installed packages within the enabled repositories and configured rules. dnf check-update returns status 100 when updates are available. dnf history shows transactions. An undo depends on availability of required versions and may fail. Red Hat does not support using it to downgrade RHEL system packages. Package history also cannot restore independent application data changes. On SUSE, zypper update updates packages, and zypper dist-upgrade aligns the system with selected repositories and may make larger changes. Follow the release-specific upgrade procedure. zypper remove --clean-deps handles unneeded dependencies.
When a transaction fails or selects an unexpected version, compare the arch, installed build, enabled repository, available candidate and dependency or conflict named in the error. For example, on a RHEL 9 host with a missing semanage, dnf provides '*/semanage' identifies packages advertising that path pattern. A repository search answers a different question from rpm -qf, which answers installed ownership. Check advisories against the installed build, since fixes may be backported.
Repository configuration, signatures and exclusions
On a DNF 4 host, a file such as /etc/yum.repos.d/lab.repo can contain a stanza like this. This uses a reserved example domain and a key file provisioned separately by the administrator.
[lab-tools]
name=Approved lab tools
baseurl=https://repo.example.test/rpm/$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/LAB-RPM-KEY
dnf repolist --all shows enabled and disabled repositories. enabled=0 disables the entry persistently, and --disablerepo=lab-tools applies to one invocation. The DNF variables are supplied by the system configuration and release data. Check the actual repository URL and release. gpgcheck=1 checks signatures of packages from this repository, using the RPM package-trust keyring. gpgkey supplies keys the tool can import if required. Verify the key fingerprint independently. repo_gpgcheck separately checks repository metadata signatures when the repository publishes them. Local RPM paths can have a separate localpkg_gpgcheck setting.
APT reads source stanzas in /etc/apt/sources.list and files under /etc/apt/sources.list.d/. A deb822 source entry may look like this:
Types: deb
URIs: https://repo.example.test/debian
Suites: bookworm
Components: main
Signed-By: /etc/apt/keyrings/lab-archive.gpg
Enabled: yes
Signed-By restricts which keyring can authenticate that source. The keyring must be readable by APT's service account. APT authenticates signed release metadata and follows checksums through the indexes to the packages. To disable this source without deleting the stanza, set Enabled: no and refresh. A one-line .list entry can be disabled by commenting out its line. On SUSE, use zypper repos to inspect entries, zypper addrepo to add a known source and zypper modifyrepo -d lab-tools to disable it. Verify trust and the suite or release before enabling any third-party source.
A repository exclusion affects a source. A package-level rule can affect transaction eligibility. With DNF 4, excludepkgs in a repository stanza filters packages from that repository. A command-line example is dnf --exclude=example upgrade. An APT hold can be set with apt-mark hold example and displayed with apt-mark showhold. Check existing pins or holds when expected updates are missing. Remove temporary holds through the applicable change process so required fixes can be evaluated.
Source and language-specific packages
Use the project's build instructions and a trusted source. In a traditional GNU Autoconf release that provides configure and supports staging through DESTDIR, a lab sequence from the unpacked source tree is:
./configure --prefix=/usr/local
make -j4
make DESTDIR="$PWD/stage" install
configure probes the build environment as defined by the project and can generate Makefiles from templates. Here make builds the software. The install target copies files to a staged tree for inspection. Review the supported make check or other project test instructions before packaging or deploying. Build options, dependencies and staging support vary. A direct install can put files outside package manager tracking.
| Tool | Use |
|---|---|
Python pip | Use a project virtual environment and its interpreter. For example, after creating a lab environment with python3 -m venv .venv, use .venv/bin/python -m pip install -r requirements.txt to install declared requirements from approved sources. |
Rust cargo | cargo build builds a Cargo project and cargo install installs binaries from a supported crate/source into Cargo's install root. |
Node.js npm | npm install installs project dependencies using the project manifests and lockfile as applicable. npm install -g targets the configured global prefix. |
Sandboxed applications and managed defaults
Snap uses snapd. Strict confinement restricts host access through declared interfaces. Classic snap confinement allows broader access, so check snap info or snap list for the installed mode. Flatpak applications use runtimes and sandbox permissions. Portals mediate some access and permissions or overrides can broaden it. flatpak list shows installed applications and runtimes. An AppImage is commonly run as a single executable file compatible with the host. It may need FUSE or an alternate extraction workflow. The format alone does not provide a sandbox.
On Debian, update-alternatives --display editor shows the link group and update-alternatives --config editor offers a selection. A generic link such as /usr/bin/editor can resolve through /etc/alternatives/editor to the selected executable. Manual selection remains in manual mode. update-alternatives --auto editor returns the group to priority-based selection. Check PATH and scripts that use a fixed executable path if a command still launches differently.
Common service configuration
| Service | What to configure or verify |
|---|---|
| DNS | In BIND, distinguish authoritative zones from recursive client service. Verify that the running instance loads the intended named.conf and includes. Check with named-checkconf and query the intended server with dig. DNS uses UDP and TCP on the standard DNS port 53. |
| NTP | With chrony, choose approved time sources in the active chrony configuration using server or pool as appropriate. chronyc sources -v inspects sources and chronyc tracking shows synchronization data. |
| PTP | With LinuxPTP, choose the participating interface, transport, clock role and compatible PTP domain. Check whether hardware timestamping is available before selecting that mode in ptp4l. PTP can use Ethernet or UDP transport. |
| DHCP | In Kea DHCPv4, select listening interfaces and define the subnet, lease pool and intended router/DNS options. Validate the candidate configuration, then compare client lease behavior and server logs. Avoid an overlapping pool and unauthorized DHCP service on a shared network. |
| HTTP/HTTPS | Apache HTTP Server uses virtual hosts and a listener configuration. Check httpd -t or the distribution's equivalent. Nginx uses server blocks with listeners and resource or proxy configuration. Use nginx -t to test the intended file before a controlled reload. Verify the expected hostname, listener and certificate configuration. |
| SMTP | Postfix uses main.cf for parameters and master.cf for service definitions. Inspect with postconf -n and postconf -M. Check interfaces, accepted domains, relay policy and the intended submission service. Port 25 is standard for SMTP relay. Submission on 587 depends on configuration. |
| IMAP4 | A server such as Dovecot lets mail clients access mailboxes. Review mail storage, authentication, TLS and listeners with doveconf -n. Ports 143 and 993 are registered for IMAP and IMAP over implicit TLS, respectively. Check the actual configured service. |
On a Rocky Linux host with RPM package records, which command asks the installed database which package owns the path /usr/bin/htop?
dnf search /usr/bin/htop
rpm -ql /usr/bin/htop
rpm -qf /usr/bin/htop
dpkg -S /usr/bin/htop
On a RHEL 9 compatible lab host using DNF 4, the approved RPM signing key is trusted. Which repository setting turns on package-signature checking for RPMs retrieved from that repository?
gpgcheck=1
repo_gpgcheck=1
localpkg_gpgcheck=1
enabled=1
An unpacked project uses an Autoconf-generated script and Makefile templates. Which step checks the build environment and accepts --prefix to set the intended installation path before make?
make
./configure
make install
cmake --build .
Sections you finish are checked off in the contents.