 <p>If your target systems are managed by reasonable people, the software will be managed by the packaging system. On Redhat, Fedora, CentOS or SUSE systems that will be RPM. On any system derived from Debian it will be APT.</p> <p>So your script can check for one of those two packaging systems. Although be warned that you can install RPM on a Debian system so the mere presence of RPM doesn't tell you the system type. Packages can also be named differently. For example, SUSE will name things a bit differently from Redhat.</p> <p>So, use <code>uname</code> and/or <code>/etc/issue</code> to determine system type. Then you can look for a particular package version with <code>rpm -q apache</code> or <code>dpkg-query -s postgresql</code>.</p> <p>If the systems are managed by lunatics, the software will be hand-built and installed in /opt or /usr/local or /home/nginx and versions will be unknown. In that case good luck.</p>