Debian Based Distros
The below command should work for Debain, Ubuntu, and the Raspberry Pi Raspbian.
dpkg --get-selections
RPM Based Distros
The following works on Fedora, CentOS, ReHat.
rpm -qa
The above commands return all of the packages installed on a system. If you want to look for a specific program or package you can use grep to filter the results.
rpm -qa | grep program
or
dpkg --get-selections | grep program