1. Listing All installed packages (.pkg) files on Mac OS X
If you are used to Linux package management (with dpkg .deb package tool or Redhat's .rpm package manager rpm command) and out of a suddeny you have to use for some time or permanently choose to migrate to Mac OS X and joined the Jailed closed Computer model of Mr. Steve Jobs.
As a Linux command addict,yYou might be wondering on how to list all installed packages on Mac OS with a command just like you use Debian / Ubuntus terminal to list installed packages and their overall state for example with dpkg with:
dpkg -l
or Fedora / CentOS to list all installed packages you're pretty much accustomed to:
rpm -qa
The same is possible in Mac OS X by opening Terminal and running cmd:
MacBook-Air:Volumes root# pkgutil –pkgs
om.apple.pkg.OSX_10_13_IncompatibleAppList.16U1254
com.apple.pkg.MRTConfigData.16U4001
com.apple.pkg.ChineseWordlistUpdate.14U1355
com.apple.pkg.GatekeeperConfigData.16U1300
com.apple.pkg.MRTConfigData.16U4003
com.apple.pkg.ChineseWordlistUpdate.14U1356
com.apple.pkg.ChineseWordlistUpdate.14U1346
com.apple.pkg.GatekeeperConfigData.16U1259
com.apple.pkg.GatekeeperConfigData.16U1265
com.apple.pkg.XProtectPlistConfigData.16U4009
com.apple.pkg.ChineseWordlistUpdate.14U1353
com.apple.pkg.ChineseWordlistUpdate.14U1347
com.apple.pkg.ChineseWordlistUpdate.14U1351
com.apple.pkg.MRTConfigData.16U4038
com.apple.pkg.iTunesX.12.7.3.delta
com.apple.pkg.XProtectPlistConfigData.14U4058
com.apple.pkg.GatekeeperConfigData.16U1138
com.apple.pkg.MLVUpdate_en_GB_daniel.16U1127
com.apple.pkg.EmbeddedOSFirmware
com.apple.pkg.MRTConfigData.16U4005
com.apple.pkg.ChineseWordlistUpdate.14U1323
com.apple.pkg.GatekeeperConfigData.16U1572
com.apple.pkg.iTunesX.12.7.delta
com.apple.pkg.MRT.14U2321
…
For the sake of convenience run it with a pipe to less cmd:
MacBook-Air:Volumes root# pkgutil –pkgs | less
To find whether a package with a certain name is installed or not
MacBook-Air:Volumes root# pkgutil –pkgs|grep -i oracle
com.oracle.jre|
To further list the content of the package (the package files contained and directory structure etc.)
MacBook-Air:Volumes root# pkgutil –files the-package-name.pkg
this is like the Linux equivalent of
dpkg -L packagename and rpm -qa rpm-packagename:
Checking the package directory location on Mac OS is done with:
MacBook-Air:Volumes root# pkgutil –pkg-info com.oracle.jre
package-id: com.oracle.jre
version: 1.0
volume: /
location: Library/Internet Plug-Ins/JavaAppletPlugin.plugin
install-time: 1523533193
2. Deleting a Mac OS X package .pkg
After reviewing the .pkg file content for smaller sized packages the best way to remove it is to manually remove all files belonging to the package (but before make sure you are not deleting an important packageand have visually closely inspected them otherwise you might break badly your Mac OS X …) you can run below 2 commands to delete package files and directory:
# pkgutil –only-files –files the-package-name.pkg | tr 'n' '