Monday, November 19, 2012

Finding a Linux Application Version

During a recent Wordpress installation endeavor, I needed to confirm I had the correct versions of Apache, PHP, etc., and didn't exactly know how to accomplish that. As with many things in the computer world, there are many ways to skin a cat...

This example uses Apache, which is httpd as a service (daemon in Linux-speak).

Add -v to the binary (or -V depending on the app), and this doesn't work for everything.
[root@spidey ~]# httpd -v
Server version: Apache/2.2.15 (Unix)
Server built:   Feb  7 2012 09:50:11

Use which to locate the full path of a command
[root@spidey ~]# which httpd
/usr/sbin/httpd

Use whereis to locate the binary, source and man pages
[root@spidey ~]# whereis httpd
httpd: /usr/sbin/httpd /usr/sbin/httpd.event /usr/sbin/httpd.worker /etc/httpd /usr/lib64/httpd /usr/share/man/man8/httpd.8.gz

Querying the installed package by using rpm -q
[root@spidey ~]# rpm -q httpd
httpd-2.2.15-15.el6_2.1.x86_64

You can do a locate to see everywhere on the system httpd shows up
[root@spidey ~]# locate httpd
/etc/httpd
/etc/httpd/conf
/etc/httpd/conf.d
/etc/httpd/logs
...

Or a find with -name

[root@spidey ~]# find / -name httpd
/etc/httpd
/etc/rc.d/init.d/httpd
/etc/sysconfig/httpd
/etc/logrotate.d/httpd
...

And yes, I did have the correct version :)