RHCSA Software Package Management Questions and Answers — Questions and Answers
Question 1: A script is failing because it cannot find the command `/usr/sbin/semanage`. A system administrator needs to determine which package provides this file so it can be installed. Which of the following commands will accomplish this?
- dnf search semanage
- rpm -qf /usr/sbin/semanage
- dnf whatprovides /usr/sbin/semanage (Correct answer)
- dnf find-file /usr/sbin/semanage
Correct answer: dnf whatprovides /usr/sbin/semanage
The `dnf whatprovides` (or its alias `dnf provides`) command is used to query repositories to find out which package owns a specific file or capability, even if the package is not currently installed. `dnf search` only searches package names and summaries. `rpm -qf` only works if the package providing the file is already installed. `dnf find-file` is not a valid dnf command.
Question 2: A system administrator needs to install the `nginx` package specifically from the 'epel' repository, which is configured but currently disabled. Which command should be used to perform the installation in a single step?
- dnf install nginx --enablerepo=epel (Correct answer)
- dnf install nginx --from-repo epel
- dnf install nginx --repo=epel
- dnf repository-install epel nginx
Correct answer: dnf install nginx --enablerepo=epel
The `--enablerepo` option tells dnf to temporarily enable the specified repository for the current transaction. This is the standard method for installing a package from a repository that is configured but not enabled by default. The other options use incorrect syntax for this operation.
Question 3: A system administrator recently ran several `dnf` updates and installations. To troubleshoot a new issue, they need to see a detailed list of what packages were installed, updated, or removed in the most recent transaction. Which command provides this specific information?
- dnf history
- dnf history list
- dnf log last
- dnf history info last (Correct answer)
Correct answer: dnf history info last
`dnf history` by itself lists all transactions with their IDs. To see the specific details of a transaction, such as which packages were altered, you use `dnf history info <ID>`. The keyword `last` is a convenient alias for the most recent transaction ID.
Question 4: After installing the `httpd` package, a system administrator wants to list all the files that were placed on the system as part of that specific package. Which of the following commands is used for this purpose?
- dnf list-files httpd
- rpm -ql httpd (Correct answer)
- rpm -qf httpd
- dnf show httpd --files
Correct answer: rpm -ql httpd
The `rpm` command is the underlying package manager and is ideal for querying the local RPM database about installed packages. The `-q` flag is for query, and `-l` lists the files owned by the specified package. The other commands are either syntactically incorrect or perform different functions.
Question 5: A system administrator is setting up a new server and needs to install all the packages required for a graphical administration interface. Which command is the most appropriate for installing the "Server with GUI" environment group?
- dnf install-collection "Server with GUI"
- dnf modules install "Server with GUI"
- dnf groupinstall "Server with GUI" (Correct answer)
- dnf install @Server-with-GUI
Correct answer: dnf groupinstall "Server with GUI"
The `dnf groupinstall` command is used to install all the packages that are part of a predefined package group or environment. "Server with GUI" is a standard environment group in Red Hat Enterprise Linux and its derivatives. While `dnf install @'Server with GUI'` also works, `dnf groupinstall` is the explicit and traditional command for this action. The other options use incorrect dnf subcommands or syntax.
Question 6: A system administrator has a third-party repository configured in `/etc/yum.repos.d/external.repo` with a repository ID of `external-repo`. To perform a system-wide update while temporarily preventing any packages from being installed or updated from this repository, which is the most effective command?
- dnf update --excluderepo=external.repo
- rm /etc/yum.repos.d/external.repo && dnf update
- dnf config-manager --set-disabled external-repo && dnf update
- dnf update --disablerepo=external-repo (Correct answer)
Correct answer: dnf update --disablerepo=external-repo
The `--disablerepo` flag is used to temporarily disable a specific repository for a single dnf transaction. This is the most direct and non-permanent way to exclude a repository for a specific command. Using `dnf config-manager` would permanently disable the repository until it is re-enabled. Removing the file is a destructive action. `--excluderepo` is not a valid dnf flag; the correct flag for excluding packages is `--exclude`.
A script is failing because it cannot find the command `/usr/sbin/semanage`.
A system administrator needs to determine which package provides this file so it can be installed.
Which of the following commands will accomplish this?