RHCSA RHCSA Software Package Management 4 — Questions and Answers
Question 1: Which command rolls back the most recent DNF transaction?
- dnf history undo last (Correct answer)
- dnf rollback
- dnf undo last
- dnf history rollback 1
Correct answer: dnf history undo last
'dnf history undo last' reverses the most recent transaction; you can also specify a transaction ID instead of 'last'.
Question 2: How do you install a specific version of a package, e.g., httpd version 2.4.37?
- dnf install httpd-2.4.37 (Correct answer)
- dnf install httpd --version 2.4.37
- dnf install httpd=2.4.37
- rpm -i httpd --version=2.4.37
Correct answer: dnf install httpd-2.4.37
DNF uses the package-version syntax 'packagename-version' (including release and arch optionally) to pin a specific version for installation.
Question 3: A package was installed via RPM but is not showing up in 'dnf list installed'. What is the most likely reason?
- rpm and dnf share the same RPM database, so this should not happen — the package would appear (Correct answer)
- The package was installed to a non-default prefix
- DNF caches are out of date
- The package has no dnf metadata
Correct answer: rpm and dnf share the same RPM database, so this should not happen — the package would appear
Both rpm and dnf use the same RPM database (/var/lib/rpm), so any rpm-installed package is visible to 'dnf list installed'.
Question 4: What does the 'dnf autoremove' command do?
- Removes packages that were installed as dependencies but are no longer needed (Correct answer)
- Removes all packages not in the Base group
- Automatically removes the oldest kernel
- Removes packages marked as auto-updated
Correct answer: Removes packages that were installed as dependencies but are no longer needed
'dnf autoremove' cleans up leaf dependency packages that were auto-installed but are no longer required by any explicitly installed package.
Question 5: How can you enable a disabled repository for a single DNF command without editing its .repo file?
- dnf --enablerepo=<repoid> install <package> (Correct answer)
- dnf enable <repoid> && dnf install <package>
- dnf install <package> --repo=<repoid>
- dnf repolist enable <repoid>
Correct answer: dnf --enablerepo=<repoid> install <package>
The --enablerepo flag temporarily enables a disabled repository for just that invocation without modifying the configuration file.
Question 6: Which RPM query shows all configuration files owned by the 'sshd' package?
- rpm -qc openssh-server (Correct answer)
- rpm -ql openssh-server
- rpm -qd openssh-server
- rpm -qi openssh-server
Correct answer: rpm -qc openssh-server
'rpm -qc' lists all configuration files (marked %config in the spec) belonging to a package.
Question 7: What happens when you run 'dnf upgrade' with no package name specified?
- All installed packages with available updates are upgraded (Correct answer)
- Only security updates are applied
- The system prompts for which packages to upgrade
- Only packages in the Base group are upgraded
Correct answer: All installed packages with available updates are upgraded
'dnf upgrade' with no arguments updates all installed packages for which newer versions exist in enabled repositories.
Which command rolls back the most recent DNF transaction?