Managing Software
This section covers software package administration in Red Hat Enterprise Linux using dnf and rpm, repository configuration (.repo), Application Streams and modularity, script security inspection, and package queries required for RHCSA preparation.
Theory Questions
1. What are the mandatory and optional components in a .repo configuration file?
A .repo configuration file defines software repository locations and metadata settings.
- Components:
- Mandatory: Repository ID enclosed in brackets (
[repoid]) and a location directive (baseurl,mirrorlist, ormetalink). - Optional:
name(descriptive name),enabled(1or0),gpgcheck(1or0), andgpgkey(URL or file path to public GPG key).
- Mandatory: Repository ID enclosed in brackets (
- Command(s):
cat /etc/yum.repos.d/*.repo - Why:
[repoid]serves as the unique identifier for DNF, whilebaseurlspecifies where package headers and RPM files are downloaded from. - Gotchas: Omitting square brackets around
[repoid]or providing an invalid URL protocol renders the repository unusable bydnf. - Verify:
dnf repolist
2. Which installation source is used when a server is not registered with Red Hat?
Unregistered servers utilize local installation media (ISO mounts) or custom local/remote HTTP/FTP repositories.
- Command(s):
grep -E "baseurl|metalink" /etc/yum.repos.d/*.repo - Why: Unregistered systems cannot authenticate against Red Hat Content Delivery Network (
cdn.redhat.com) repositories viasubscription-manager. - Gotchas: Assuming
subscription-manageris the only software source. Offline and lab environments rely heavily on local ISO repo configurations. - Verify:
subscription-manager status(returnsOverall Status: Not Registered).
3. How do you configure a .repo file to point to a local file system directory?
Define a repository stanza using the file:// protocol prefix followed by the absolute path.
- Command(s):
cat <<EOF> /etc/yum.repos.d/local.repo [local] name=Local File Repository baseurl=file:///myrepo enabled=1 gpgcheck=0 EOF
* **Why:** `file:///` uses three slashes: two for the `file://` scheme and one for the root directory `/myrepo`.
* **Gotchas:** Using only two slashes (`file://myrepo`) creates an invalid URI syntax. Omitting `gpgcheck=0` causes package installations to fail if custom local RPMs lack GPG signatures.
* **Verify:** `dnf repolist local`
---
### 4. How does GPG-based repository security protect package installation?
GPG (GNU Privacy Guard) signing cryptographically verifies that RPM packages originate from a trusted vendor and have not been altered.
* **Command(s):** `dnf repolist -v | grep -i gpg`
* **Why:** Setting `gpgcheck=1` instructs DNF to validate the digital signature of every downloaded RPM against trusted public keys imported into the RPM database.
* **Gotchas:** Do not confuse GPG package signature verification with SSL/TLS transport encryption (`https://`).
* **Verify:** `rpm -q gpg-pubkey`
---
### 5. How do you find which package provides a specific file or command (e.g., `semanage`)?
Execute `dnf provides` using wildcard matching.
* **Command(s):** `dnf provides "*/semanage"`
* **Why:** `provides` (or `whatprovides`) queries repository metadata to identify uninstalled or installed packages that contain the specified file path.
* **Gotchas:** Omitting the `*/` wildcard forces DNF to match an exact path string, which fails if the exact binary directory location is unknown.
* **Verify:** `dnf provides "*/semanage"` (returns `policycoreutils-python-utils`).
---
### 6. Which DNF module component allows multiple application versions to exist in metadata side-by-side?
**Module Streams** represent distinct versions of an application stream (e.g., PHP 7.4 vs. PHP 8.1).
* **Command(s):** `dnf module list`
* **Why:** Application Streams decouple software version release cycles from the core operating system release version, allowing admins to select specific software versions.
* **Gotchas:** Do not confuse module **streams** (versions) with module **profiles** (predefined package sets such as `common`, `devel`, or `minimal`).
* **Verify:** `dnf module list php`
---
### 7. How do you install a specific profile of an application stream (e.g., PHP 8.1 `devel` profile)?
Specify the stream and profile using the syntax `module_name:stream/profile`.
* **Command(s):** `dnf module install php:8.1/devel`
* **Why:** `php:8.1` enables the 8.1 stream, while `/devel` selects the development package profile associated with that stream.
* **Gotchas:** If a different stream is already active, reset the module first using `dnf module reset php` before switching streams.
* **Verify:** `dnf module list php` (displays `[e]` for enabled and `[i]` for installed on stream `8.1`).
---
### 8. How do you install a locally downloaded RPM package file while automatically resolving dependencies?
Pass the local file path directly to `dnf install`.
* **Command(s):** `dnf install ./package.rpm -y`
* **Why:** `dnf install` inspects local RPM headers and queries enabled repositories to download and install any missing required dependencies.
* **Gotchas:** Using low-level `rpm -ivh package.rpm` fails if the package has unfulfilled dependencies, as `rpm` does not pull packages from repos.
* **Verify:** `rpm -q package_name`
---
### 9. How do you determine which installed RPM package owns a specific file on disk?
Query the local RPM database using `rpm -qf`.
* **Command(s):** `rpm -qf /usr/bin/ls`
* **Why:** `-q` initiates a query and `-f` specifies the absolute file path on disk.
* **Gotchas:** The file must currently exist on the target system for `rpm -qf` to work; otherwise, use `dnf provides`.
* **Verify:** `rpm -qf /usr/bin/ls` (returns `coreutils`).
---
### 10 & 16. How do you inspect a downloaded RPM package for installation scripts without installing it?
Query the uninstalled RPM file using `rpm -qp --scripts`.
* **Command(s):** `rpm -qp --scripts package.rpm`
* **Why:** `-p` targets an uninstalled package file, and `--scripts` displays pre-installation (`%pre`), post-installation (`%post`), pre-uninstallation (`%preun`), and post-uninstallation (`%postun`) shell scripts.
* **Gotchas:** Omitting `-p` causes `rpm` to search the local database for an installed package named `package.rpm` instead of reading the file on disk.
* **Verify:** `rpm -qp --scripts package.rpm | head -n 20`
---
### 11. How do you configure a repository file to point to a remote HTTP server?
Define a `.repo` file using the `http://` or `https://` protocol in the `baseurl` entry.
* **Command(s):**
```bash
cat <<EOF> /etc/yum.repos.d/remote.repo
[remote]
name=Remote HTTP Repository
baseurl=[http://example.com/repo/BaseOS/](http://example.com/repo/BaseOS/)
enabled=1
gpgcheck=0
EOF
- Why: Directs DNF to pull repository metadata and RPM packages over network HTTP/HTTPS protocols.
- Gotchas: Ensure firewall rules permit outbound network access on port 80 (HTTP) or port 443 (HTTPS).
- Verify:
dnf repolist remote
12. How do you verify that a newly configured repository is enabled and accessible?
Run dnf repolist to inspect active repositories and package counts.
- Command(s):
dnf repolist - Why: Forces DNF to parse repository configuration files in
/etc/yum.repos.d/, test connectivity, and output enabled repo IDs with total package counts. - Gotchas:
dnf repolistonly shows enabled repositories. To inspect disabled repositories, usednf repolist --all. - Verify:
dnf repolist
13. How do you search for the package containing a specific administrative command (e.g., useradd)?
Query path binaries using dnf provides.
- Command(s):
dnf provides "*/useradd" - Why: Searches repository file lists to match binaries located in system directories (such as
/usr/sbin/useradd). - Gotchas: Searching
useraddwithout quotes or path wildcards will fail if DNF evaluates it purely as an exact package name. - Verify:
dnf provides "*/useradd"(returnsshadow-utils).
14. How do you view a DNF group name and inspect its package membership?
Use dnf group info passing the group name enclosed in quotes.
- Command(s):
dnf group info "Server with GUI" - Why: Displays group descriptions along with mandatory, default, and optional package lists contained within that environment group.
- Gotchas: Group names containing spaces must be wrapped in quotes; otherwise, DNF treats each word as an individual argument.
- Verify:
dnf group info "Server with GUI"
15. How do you lock or activate a specific Application Stream version (e.g., PHP 7.4) without installing packages?
Enable the module stream using dnf module enable.
- Command(s):
dnf module enable php:7.4 - Why:
module enablesets the default active stream for the module in DNF metadata without triggering immediate package downloads or installations. - Gotchas: If another stream is currently active, run
dnf module reset phpbefore enabling a different stream. - Verify:
dnf module list php(shows[e]next to stream7.4).
17. How do you list all documentation files contained within an uninstalled RPM package file?
Query package documentation files using rpm -qpd.
- Command(s):
rpm -qpd package.rpm - Why:
-qqueries,-ptargets an uninstalled RPM file, and-dfilters output to show documentation files (man pages, READMEs, license files). - Gotchas: Using
-qloutputs all files inside the package, requiring manual filtering to isolate documentation paths. - Verify:
rpm -qpd package.rpm | grep "/usr/share/doc"
18. How do you query software packages available across enabled repositories that are not currently installed?
List uninstalled software using dnf list available.
- Command(s):
dnf list available - Why: Queries enabled repository metadata and filters out packages that are already installed on the local system.
- Gotchas: Running
rpm -qaqueries only installed packages on the system, ignoring uninstalled software available in repositories. - Verify:
dnf list available | head -n 15
Lab Tasks
Package Management Practice
Configure a local RPM software repository, perform advanced DNF package queries, inspect RPM package scripts, and manage package installation lifecycles.
Configuration Steps
# 1. Create a local repository directory
mkdir -p /myrepo
# 2. Mount installation ISO media to /mnt
mount /dev/sr0 /mnt
# 3. Copy RPM packages from installation media to the local repository directory
cp /mnt/BaseOS/Packages/*.rpm /myrepo/ 2>/dev/null
cp /mnt/AppStream/Packages/*.rpm /myrepo/ 2>/dev/null
# 4. Install repository creation utilities and generate metadata
dnf install -y createrepo
createrepo /myrepo
# 5. Create the local repository configuration file
cat <<EOF> /etc/yum.repos.d/local.repo
[local]
name=Local ISO Repository
baseurl=file:///myrepo
enabled=1
gpgcheck=0
EOF
# 6. Search for the package containing the cache-only DNS daemon (named)
dnf provides "*/named"
# 7. Perform detailed package queries on the target package (bind) without installing
dnf repoquery -l bind # List contained file paths
dnf repoquery --requires bind # List package dependencies
dnf repoquery --doc bind # List documentation files
dnf repoquery --conf bind # List configuration files
# 8. Download the package RPM locally and inspect embedded scripts
dnf download bind
rpm -qp --scripts bind-*.rpm
# 9. Install the package
dnf install bind -y
# 10. Undo installation by removing the package
dnf remove bind -y
-
Why:
-
createrepoconstructs the requiredrepodatadirectory XML database files used by DNF to query software packages. -
dnf repoqueryqueries repository package details remotely or locally without installing packages on the system. -
dnf downloadretrieves the.rpmarchive file to the local directory for static file and script inspection. -
rpm -qp --scriptsallows auditing pre/post installation scriptlets before system deployment. -
Gotchas:
-
Running
createrepois mandatory after copying RPM files; omitting this step leaves DNF unable to parse directory metadata. -
rpm -qcommands require packages to be installed first; usednf repoqueryorrpm -qpfor uninstalled packages.
Verification Procedures
Verify repository status, package script audit data, and package installation states.
# Verify local repository availability and package count
dnf repolist local
# Verify bind package removal status
rpm -q bind