pkgutil can be used to query Mac OS X Installer packages on Mac. This can be useful to get information about various packages and files. Here are some quick use cases where pkgutil can be used:
List all packages
To list all installed packages on mac:
$ pkgutil --pkgs
List files of a package
To lists files of a package:
$ pkgutil --files com.apple.pkg.JavaEssentials
To list only directories of a package:
$ pkgutil --files com.apple.pkg.JavaEssentials --only-dirs
List package name for a file
To list which package a file belongs to (if any):
$ pkgutil --file-info /bin/bash volume: / path: /bin/bash pkgid: com.apple.pkg.BaseSystemBinaries pkg-version: 10.10.0.1.1.1425657145 install-time: 1442975500 uid: 0 gid: 0 mode: 555 pkgid: com.apple.pkg.update.security.10.9.5.13F1112.2015.006 pkg-version: 1.0.0.0.1.1306847324 install-time: 1442777342 uid: 0 gid: 0 mode: 555
Note that you cannot query packages others than Mac OS X Installer packages using pkgutil.