Linux Administration
medium

Pregunta de Linux Administration #019e3987

Enunciado de la Pregunta
Linux Administration
#rpm
#rpm -qf
#/etc/exports
#package-query
Medio

Which RPM command will output the name of the package which supplied the file /etc/exports?

A

rpm -F /etc/exports

B

rpm -qf /etc/exports

Correcto
C

rpm -Kl /etc/exports

D

rpm -qp /etc/exports

E

rpm -qi /etc/exports

Explicación Oficial / Explicaciones de la Comunidad

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 -F option 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 -K option is for checking signatures (e.g., GPG) of a package file. -l is for listing files in a package. Combined, -Kl is invalid; -K expects a package file, not a system file path. This would produce an error.
  • D (rpm -qp /etc/exports): The -q is query, -p indicates query an uninstalled package file (a .rpm file). The argument should be a package file, not a system file. This would fail because /etc/exports is not a package file.
  • E (rpm -qi /etc/exports): The -q is query, -i is 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.