and rpm -qf
work for directories as well. Take in mind that all the default system directories are provided by the package filesystem
. Others could have been created by other packages, but some (parent) directories don't belong to any package if they have been created together with their sub-directories. For example on my CentOS system I have a directory named /opt/intel/composerxe-2011.0.084 and
$ rpm -qf /opt/intel/composerxe-2011.0.084
but if I try the parent directory /opt/intel I get no results:
$ rpm -qf /opt/intel
file /opt/intel is not owned by any package
even if it has been created from the aforementioned intel packages.