LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 10-05-2004, 04:04 AM   #1
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Question How to find out kernel version in a shell script?


How do I find out the version of the kernel running in a bash shell script? If this is not possible, can anyone tell me a work-around for the following problem?:

I have an application that requires the initial configuration (VMware) to be specific to the kernel that it is to be run under. I configured it to 2.4.x and it worked fine, however I added the 2.6.7 kernel to lilo as an additional option. I tried to run the startup script under 2.6.7 and it obviously said it was not configured correctly.

After returning to 2.4.x, I found that trying to run under 2.6.7 altered the configuration and it was not reconfigurable, therefore I had to reinstall, recompile, and reconfigure. I would like to make it so the startup script does not run if the running kernel is not 2.4.x. Is there a way to do this? Thanks.
ta0kira
 
Old 10-05-2004, 04:26 AM   #2
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
this gives you the kernel version:

Code:
uname -r
 
Old 10-05-2004, 04:30 AM   #3
fiomba
Member
 
Registered: Sep 2004
Posts: 63

Rep: Reputation: 15
... I hadn't see the previous answer (win32sux) ....

# kernel version

# if you only want to display the kernel version...
echo Kernel is `uname -r` # pay attention to the backticks!

# else if you want to store in a variable (kernel_version)
kernel_version=`uname -r`
echo $kernel_version

# the output of this script should be:
Kernel is 2.6.3-4mdk
2.6.3-4mdk












Last edited by fiomba; 10-05-2004 at 04:56 AM.
 
Old 10-05-2004, 04:54 AM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Original Poster
Rep: Reputation: Disabled
Thanks for the fast responses.
ta0kira
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script to find a particular string Prasun1 Linux - General 5 08-30-2005 09:23 AM
Find out distribution + version (NOT: kernel version!) Tajci Red Hat 5 06-08-2005 03:17 PM
shell script version of round robin algorithm vishamr2000 Linux - Security 0 05-19-2005 04:45 AM
find shell script help liren Linux - Newbie 3 05-02-2005 03:05 PM
how to find the pid of a perl script from shell script toovato Linux - General 1 12-19-2003 06:25 PM


All times are GMT -5. The time now is 10:10 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration