Macos – How to find out a file belongs to which package in Mac OS X

homebrewmacmacosmacports

Is there a way to find out which Application / package owns or creates a specific file? For example, in Linux these commands will show the package owner

apt-file /bin/progname

rpm -qf /bin/progname

yum whatprovides /bin/progname

In OS X, a file could be part of a native OS X application, or installed by Macports or Homebrew. These are completely different environments. Are there commands for each environment to check which application / package owns a specific file?

Best Answer

It's a little late, but perhaps it will be of help to others.

You can use the pkgutil command.

For example, if you want to know what package the "less" command belongs to run:

pkgutil --file-info /usr/bin/less

Which will output something like:

volume: /
path: /usr/bin/less

pkgid: com.apple.pkg.BaseSystemBinaries
pkg-version: 10.7.0.1.1.1309742044
install-time: 1310407891
uid: 0
gid: 0
mode: 755

To list all files contained in a package, com.apple.pkg.BaseSystemBinaries in our example, run:

pkgutil --files com.apple.pkg.BaseSystemBinaries

I know this tool has been present since OS X 10.6.

Related Question