There is a lot of different ways a Linux system can be configured. Today, most admin’s opt to stick fairly close to the suggested upgrade path for most binaries and system components. Unfortunately, there are always times when documentation is lacking or you inherited a system you know nothing about. Let’s look at a few ways of figuring out what versions the key components our systems are running.
Kernel Version
First, let’s check out the Kernel version. The kernel can be found in the /boot directory. Typically named by version a simple “ls” will show us what kernels are out there.
[root@testsys01 ~]# ls /boot config-2.6.32-220.el6.i686 symvers-2.6.32-279.11.1.el6.i686.gz config-2.6.32-279.11.1.el6.i686 symvers-2.6.32-279.14.1.el6.i686.gz config-2.6.32-279.14.1.el6.i686 symvers-2.6.32-279.2.1.el6.i686.gz config-2.6.32-279.2.1.el6.i686 symvers-2.6.32-279.5.2.el6.i686.gz config-2.6.32-279.5.2.el6.i686 System.map-2.6.32-220.el6.i686 efi System.map-2.6.32-279.11.1.el6.i686 grub System.map-2.6.32-279.14.1.el6.i686 initramfs-2.6.32-220.el6.i686.img System.map-2.6.32-279.2.1.el6.i686 initramfs-2.6.32-279.11.1.el6.i686.img System.map-2.6.32-279.5.2.el6.i686 initramfs-2.6.32-279.14.1.el6.i686.img vmlinuz-2.6.32-220.el6.i686 initramfs-2.6.32-279.2.1.el6.i686.img vmlinuz-2.6.32-279.11.1.el6.i686 initramfs-2.6.32-279.5.2.el6.i686.img vmlinuz-2.6.32-279.14.1.el6.i686 lost+found vmlinuz-2.6.32-279.2.1.el6.i686 symvers-2.6.32-220.el6.i686.gz vmlinuz-2.6.32-279.5.2.el6.i686
Since there are multiple we can look at the dates with some additional options or infer the highest version number is whats running. A safer bet might be to find out with another command. There are several as you can see below they all print about the same thing.
[root@testsys01 ~]# uname -r 2.6.32-279.14.1.el6.i686 [root@testsys01 ~]#cat /proc/version Linux version 2.6.32-279.14.1.el6.i686 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) ) [root@testsys01 ~]# dmesg | grep "Linux version" Linux version 2.6.32-279.14.1.el6.i686 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) )
Ok, so we now have without a doubt exposed the kernel version. Next, lets look for the actual version of our distribution. I personal run a lot of Centos system so let’s see what one in particular is running on my test machine.
[root@testsys01 ~]# cat /etc/redhat-release CentOS release 6.3 (Final)
You can wildcard to catch more options if you must:
[root@testsys01 ~]# cat /etc/*release*
Application Versions
In addition to knowing the version number of the system itself you typically need to know the version of installed components as well. Typically the “-v” or “—version” option exposes this. Let’s look at Apache, Net-SNMP, PHP, PERL, BASH and BIND DNS server.
[root@testsys01 ~]# httpd -v Server version: Apache/2.2.15 (Unix) Server built: Feb 13 2012 22:25:23 [root@testsys01 ~]# snmpd -v NET-SNMP version: 5.5 Web: http://www.net-snmp.org/ Email: net-snmp-coders@lists.sourceforge.net [root@testsys01 ~]# php -v PHP 5.3.3 (cli) (built: Jul 3 2012 16:40:30) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies [root@testsys01 ~]# perl -v This is perl, v5.10.1 (*) built for i386-linux-thread-multi [root@testsys01 ~]# bash --version GNU bash, version 4.1.2(1)-release (i386-redhat-linux-gnu) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html [root@testsys01:~]# named -v BIND 9.7.3
Finally, Its fairly simple to gather the version info from MySQL as well but does require you to login.
[root@testsys01 ~]# mysqladmin -u root -p version Enter password: mysqladmin Ver 8.42 Distrib 5.1.66, for redhat-linux-gnu on i386 Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Server version 5.1.66 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/lib/mysql/mysql.sock Uptime: 3 days 2 hours 9 min 33 sec Threads: 1 Questions: 396 Slow queries: 0 Opens: 29 Flush tables: 1 Open tables: 17 Queries per second avg: 0.1