Is there any way to list all .pkg packages that I have installed? Just wondering if there is any Terminal command to do this, because I think my OSX was already messed up with some incompatible .pkg installations.
Thanks.
The package management system used by OS X is rudimentary when compared to Linux counterparts like RPM or DEB. Fortunately, basic operations like listing packages and its contents are possible:

Everytime a .pkg file is installed a BOM file is stored in /private/var/db/receipts/. You can either do ls in that directory or use pkgutil to list installed packages:

$ pkgutil --packages
(...)
com.apple.pkg.HP_Scan
com.apple.pkg.HP_Scan3
com.apple.pkg.HP_SmartX
com.apple.pkg.InstallMacOSX
com.apple.pkg.JavaEssentials
com.apple.pkg.JavaForMacOSX107
com.apple.pkg.JavaMDNS
com.apple.pkg.JavaSecurity
com.apple.pkg.JavaTools
com.apple.pkg.MBP91
com.apple.pkg.MediaFiles
com.apple.pkg.MobileDevice
com.apple.pkg.MobileDeviceDevelopment
com.apple.pkg.OxfordDictionaries
(...)


To query the .pkg file's contents use pkgutil:

$ pkgutil --files com.apple.pkg.Pages4 | less
Applications
Applications/Pages.app
Applications/Pages.app/Contents
Applications/Pages.app/Contents/CodeResources
Applications/Pages.app/Contents/Frameworks
Applications/Pages.app/Contents/Frameworks/Inventor.framework
Applications/Pages.app/Contents/Frameworks/Inventor.framework/Inventor


or lsbom:

$ lsbom /private/var/db/receipts/com.apple.pkg.Pages4.bom | less
.   40775   0/0
./Applications  40775   0/80
./Applications/Pages.app    40755   0/0
./Applications/Pages.app/Contents   40755   0/0
./Applications/Pages.app/Contents/CodeResources 120755  0/0 28  2941952436  _CodeSignature/CodeResources
./Applications/Pages.app/Contents/Frameworks    40755   0/0
./Applications/Pages.app/Contents/Frameworks/Inventor.framework 40755   0/0
(...)


See man pkgutil and man lsbom for other options.