There is an easy way, that does not require root authority to determine the currently active kernel. The command to do this is called
"uname". You can type "
info uname" to see all the options available.
The simplest form is "
uname -r" which will give you the currently running kernel.
There are several other ways to do this, but some require root authorization (i.e.
cat /etc/lilo.conf or
cat /boot/grub/grub.conf). You could also do a "
ll /boot/vmlinu*" to see what kernels are in the boot directory (this is useful if you've loaded a new kernel and then discover that you have a lot of kernels - you havent't performed a "
rpm -e kernel-2.4.22-1.2122"
I usually run this after a new kernel install so that I never have more than 2 versions of my kernel.
In order to make life even easier, I developed a script that not only tells you which kernel is currently running but how long the system has been running, and the kernels installed on your system. I am including it below
Code:
#!/bin/sh
#
# The purpose of this script is to tell query which kernel
# is currently running on your system...
#
#
# Feb 25, 2004 by Ed Gurski (ed@gurski.com)
#
KERNEL="`uname -r`" # Get the name of the current kernel
UPTIME="`uptime`" # Determine how long the system has been running
RPM="`rpm -qa|grep kernel-2|sort`" # Show all installed kernels on this system
clear
echo ""
echo $UPTIME|
while read a b c d e f
do
echo "As of $a the system has been up for $c days and $e hours"
done
echo ""
echo "The running kernel is =====> $KERNEL"
echo ""
echo "The Kernels installed on this system are:"
echo "$RPM"
echo ""
You can call this antything you like, but I woud place it in "/usr/local/bin". You can also change the "grep kernel-2" to "grep kernel" if you have legacy kernels or if you want to see what kernel utilities are also loaded. I am also including a sample output from this command that I call "which_kernel"
Code:
As of 11:00:11 the system has been up for 6 days and 22:32, hours
The running kernel is =====> 2.4.22-1.2174.nptl
The Kernels installed on this system are:
kernel-2.4.22-1.2166.nptl
kernel-2.4.22-1.2174.nptl
Enjoy