65.6 Using Uname

The uname command enables you to find the current kernel version of your Linux environment. However, you might need to modify the results from the uname command to get your kernel versions to match.

The following steps modify the uname command to provide the value you need:

  1. To obtain your current kernel version, enter:

    uname -r
    

    Write down the version number so you can use it in Step 4. This example uses version 2.6.13-15-smp from a SLES 9 SP2 installation.

  2. To create a new directory, enter:

    mkdir /bin/orig
    
  3. To move the uname binary to the /bin/orig directory that you just created, enter:

    mv /bin/uname /bin/orig/uname
    
  4. Use a Linux editor (such as vi) to create the /bin/uname file that contains the following lines:

    #!/bin/sh
    
    if [ $KRNLVERSION"a" = "a" ] ; then
    
      if [ $(/bin/orig/uname -r) = "2.6.13-15-smp" ] ; then
    
        export KRNLVERSION=2.6.13-15-smp
    
       else
    
        export KRNLVERSION=2.4.31
    
      fi
    
    fi
    
    if [ $1"a" = "-ra" ] ; then
    
      echo $KRNLVERSION
    
    else
    
       /bin/orig/uname $*
    
    
    fi
    

    IMPORTANT:Replace the string “2.6.13-15-smp” with the version you found in Step 1.

  5. To make the new uname command script executable, enter:

    chmod +x /bin/uname
    
  6. Enter the following to cause the uname -r command to return a specific version, such as when compiling a module:

    export KRNLVERSION="2.6.5-7.191"
    
  7. Following the manufacturer’s directions, compile the module using the appropriate make command.

  8. Reset uname so that it returns actual values:

    unset KRNLVERSION