Questão de Linux Administration #019e3987
Which RPM command will output the name of the package which supplied the file /etc/exports?
rpm -F /etc/exports
rpm -qf /etc/exports
rpm -Kl /etc/exports
rpm -qp /etc/exports
rpm -qi /etc/exports
Explicação Oficial / Explicações da Comunidade
Summary
The question asks which RPM command identifies the package that owns a specific file, /etc/exports. RPM (Red Hat Package Manager) maintains a database of installed packages and their files. The -qf option queries the database to find which package provided a given file. This is a common task for system administrators when troubleshooting or auditing package ownership.
How it Works
RPM stores metadata about installed packages in a local database, typically located at /var/lib/rpm/. This database includes a list of all files installed by each package, along with checksums, permissions, and timestamps. When you run rpm -qf /path/to/file, RPM searches the database for the package that installed that exact file path. It uses the file's absolute path to match against the file list of each package. The query returns the package name (and version) if found, or an error message if the file is not owned by any installed package.
Why the correct answer is right
Option B (rpm -qf /etc/exports) is correct. The -q flag stands for query, and -f (or --file) specifies that the argument is a file path. Together, -qf tells RPM to query the package that owns the given file. Running this command will output something like nfs-utils-1.3.3-12.el7.x86_64 (depending on the system), indicating that the /etc/exports file was installed by the nfs-utils package.
Why incorrect options are wrong
- A (
rpm -F /etc/exports): The-Foption is used for freshening packages (upgrading only if an older version is installed). It does not query the database; it expects package files as arguments, not a file path. This would fail or do nothing. - C (
rpm -Kl /etc/exports): The-Koption is for checking signatures (e.g., GPG) of a package file.-lis for listing files in a package. Combined,-Klis invalid;-Kexpects a package file, not a system file path. This would produce an error. - D (
rpm -qp /etc/exports): The-qis query,-pindicates query an uninstalled package file (a.rpmfile). The argument should be a package file, not a system file. This would fail because/etc/exportsis not a package file. - E (
rpm -qi /etc/exports): The-qis query,-iis for package information (name, version, description, etc.). This expects a package name as argument, not a file path. Running this would try to query a package named/etc/exports, which does not exist, resulting in an error.