LFCS Software Package Management Questions and Answers — Questions and Answers
Question 1: A system administrator on a RHEL-based server needs to determine which installed package provides the '/usr/sbin/sshd' executable. Which of the following commands will accomplish this most directly?
- dnf info sshd
- rpm -ql openssh-server
- dnf provides /usr/sbin/sshd
- rpm -qf /usr/sbin/sshd (Correct answer)
Correct answer: rpm -qf /usr/sbin/sshd
The `rpm -qf /path/to/file` command is the correct tool for querying the RPM database to find out which installed package owns a specific file. `dnf provides` is also useful, especially for finding packages that are not yet installed, but `rpm -qf` is the most direct method for an existing file. `rpm -ql` lists files in a package, and `dnf info` shows package details, both of which require knowing the package name beforehand.
Question 2: On a Debian or Ubuntu system, what is the primary purpose of running the `apt update` command?
- To download and install the latest versions of all currently installed packages.
- To remove obsolete packages and free up disk space.
- To resynchronize the local package index files from their sources in the configured repositories. (Correct answer)
- To check the integrity of all installed packages and report any modified files.
Correct answer: To resynchronize the local package index files from their sources in the configured repositories.
The `apt update` (or `apt-get update`) command downloads the latest package information from all configured repositories. It updates the local database with metadata about what packages and versions are available, but it does not install or upgrade any software itself. This step is necessary before running `apt upgrade` to ensure the system knows what updates are available.
Question 3: A system administrator needs to install a custom application provided as a local file named `app-utility-1.2.deb` on an Ubuntu server. The installation fails because of missing dependencies. Which command should the administrator use to install the local file and automatically resolve and install its dependencies from the configured repositories?
- dpkg -i app-utility-1.2.deb
- apt-get install ./app-utility-1.2.deb (Correct answer)
- apt-get build-dep app-utility-1.2.deb
- dpkg --unpack app-utility-1.2.deb
Correct answer: apt-get install ./app-utility-1.2.deb
While `dpkg -i` is used to install `.deb` files, it does not handle dependency resolution. The modern `apt` and `apt-get` commands can install local `.deb` files (by providing a path like `./filename.deb`) and will use their repository knowledge to automatically find, download, and install any required dependencies at the same time.
Question 4: Which of the following is a key advantage of using a high-level package manager like `dnf` or `apt` compared to a low-level tool like `rpm` or `dpkg`?
- They allow for the installation of packages directly from source code.
- They automatically resolve and install required software dependencies from repositories. (Correct answer)
- They provide more granular control over individual file permissions during installation.
- They are the only tools that can list the files contained within a package.
Correct answer: They automatically resolve and install required software dependencies from repositories.
The primary function and main advantage of high-level package managers like `dnf` and `apt` is their ability to perform automatic dependency resolution. When you request to install a package, they check its dependencies, find the required packages in the configured repositories, and install them automatically. Low-level tools like `rpm` and `dpkg` will typically fail if a dependency is not met, requiring manual intervention.
Question 5: A system administrator on a CentOS server suspects that a configuration file, `/etc/chrony.conf`, has been modified since the `chrony` package was installed. Which command should be used to verify the integrity of the `chrony` package and see a report of any altered files?
- dnf check chrony
- rpm -qf /etc/chrony.conf
- rpm -V chrony (Correct answer)
- dnf deplist chrony
Correct answer: rpm -V chrony
The `rpm -V` or `rpm --verify` command checks the files of an installed package against the metadata stored in the RPM database. It reports on discrepancies in size, permissions, type, owner, group, MD5 checksum, and modification time, making it the ideal tool for verifying file integrity.
Question 6: You have downloaded a package file named `newtool-1.5.el8.x86_64.rpm` but have not yet installed it. You need to list all the dependencies this package requires before proceeding with the installation. Which command will query the package file directly to show this information?
- rpm -qR newtool-1.5.el8.x86_64.rpm (Correct answer)
- dnf deplist newtool
- rpm -q --whatrequires newtool-1.5.el8.x86_64.rpm
- dnf provides newtool
Correct answer: rpm -qR newtool-1.5.el8.x86_64.rpm
To query the metadata of a package *file* (that is not yet installed), you use the `rpm` command with the `-q` (query) and `-p` (package file) flags. Adding the `-R` (requires) flag lists the package's dependencies. Therefore, `rpm -qpR <filename.rpm>` is the correct command. The form `rpm -qR` without `-p` queries an already installed package.
A system administrator on a RHEL-based server needs to determine which installed package provides the '/usr/sbin/sshd' executable.
Which of the following commands will accomplish this most directly?