Sponsored Content
Full Discussion: Determine Linux Version.
Operating Systems Linux Slackware Determine Linux Version. Post 92528 by vino on Monday 12th of December 2005 10:16:30 AM
Old 12-12-2005
Check this post- which machine. The script in that detects your OS version.

Yet another script I found on the net.
Code:
 # Determine the Linux distribution and version that is being run.
   #
   # Check for GNU/Linux distributions
   if [ -f /etc/SuSE-release ]; then
     DISTRIBUTION="suse"
   elif [ -f /etc/UnitedLinux-release ]; then
     DISTRIBUTION="united"
  elif [ -f /etc/debian_version ]; then
    DISTRIBUTION="debian"
  elif [ -f /etc/redhat-release ]; then
    a=`grep -i 'red.*hat.*enterprise.*linux' /etc/redhat-release`
    if test $? = 0; then
      DISTRIBUTION=rhel
    else
      a=`grep -i 'red.*hat.*linux' /etc/redhat-release`
      if test $? = 0; then
        DISTRIBUTION=rh
      else
        a=`grep -i 'cern.*e.*linux' /etc/redhat-release`
        if test $? = 0; then
          DISTRIBUTION=cel
        else
          a=`grep -i 'scientific linux cern' /etc/redhat-release`
          if test $? = 0; then
            DISTRIBUTION=slc
          else
            DISTRIBUTION="unknown"
          fi
        fi
      fi
    fi
  else
    DISTRIBUTION="unknown"
  fi

  ###    VERSION=`rpm -q redhat-release | sed -e 's#redhat[-]release[-]##'`

  case ${DISTRIBUTION} in
  rh|cel|rhel)
      VERSION=`cat /etc/redhat-release | sed -e 's#[^0-9]##g' -e 's#7[0-2]#73#'`
      ;;
  slc)
      VERSION=`cat /etc/redhat-release | sed -e 's#[^0-9]##g' | cut -c1`
      ;;
  debian)
      VERSION=`cat /etc/debian_version`
      if [ ${VERSION} = "testing/unstable" ]; then
          # The debian testing/unstable version must be translated into
          # a numeric version number, but no number makes sense so just
          # remove the version all together.
          VERSION=""
      fi
      ;;
  suse)
      VERSION=`cat /etc/SuSE-release | grep 'VERSION' | sed  -e 's#[^0-9]##g'`
      ;;
  united)
      VERSION=`cat /etc/UnitedLinux-release`
      ;;
  *)
      VERSION='00'
      ;;
  esac;

  echo ${DISTRIBUTION}${VERSION}

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Determine Unix Version

Is there a trick to determine the exact version from Unix that one is working with? I would have expected to see it after logon, but all I get are some Copyright-messages... I know it's some HP-UX, but I would like to know the version-number Tnx in advance! Dave (2 Replies)
Discussion started by: davegeysemans
2 Replies

2. UNIX for Dummies Questions & Answers

Cmd to determine my OS version?

I'm looking for a generic (i.e. would be resident in most/all unix flavors) internal command for determining my OS and version. When I telnet to a box here @ work, I get none of that info and can't remember the equivalent of the DOS ver command; I know I used to know this! Thanks. (2 Replies)
Discussion started by: brian.wilson
2 Replies

3. Solaris

Determine LOM version?

Is there a way I can determine the LOM version on a Sun machine without actually shutting the system down? I'm confused. :) (2 Replies)
Discussion started by: sysera
2 Replies

4. UNIX for Dummies Questions & Answers

How do I see which version of Linux I am using ?

I want to know the distribution and version of linux that I am running: uname -r gives me: 2.4.20-8bldsmp uname -v gives me: #1 SMP Wed Sep 20 19:32:24 PDT 2006 Whats the distribution ? and whats the version ? thanks !!! (1 Reply)
Discussion started by: the_learner
1 Replies

5. Linux

Why is there so many linux version?

Hi, Why is there many different Linux names and SO instead to be only one? What are the differences? Paul Weinstock (3 Replies)
Discussion started by: Paul Weinstock
3 Replies

6. Shell Programming and Scripting

need to know the version of Linux

Hi I have run the command uname -a and i got the below output Linux vm07 2.6.9-77.Emp #1 SMP Wed Nov 7 13:58:04 EST 2007 i686 i686 i386 GNU/Linux i want know the version of Linux can i get it from above output if yes then what is it? is it 2.6.9-77.Emp? (2 Replies)
Discussion started by: aish11
2 Replies

7. Linux

Linux Version of IE?

Is there a linux version of IE? (5 Replies)
Discussion started by: billcrosby
5 Replies

8. Shell Programming and Scripting

Portable Shell Script - Determine Which Version of Binary is Installed?

I currently have a shell script that utilizes the "Date" binary - this application is slightly different on OS X (BSD General Commmand) and Linux systems (gnu date). In particular, the version on OS X requires the following to get a date 14 days in the future "date -v+14d -u +%Y-%m-%d" where gnu... (1 Reply)
Discussion started by: colinjohnson
1 Replies

9. Shell Programming and Scripting

Using Linux to determine version of Windows

This is an odd question and I didn't really know what category it fits. I just installed Ubuntu 12.10. During the installation process, the screen informed me that Windows 7 was installed in a particular partition. I'm just wondering how this was accomplished. Using 'fdisk -l' will indicate... (1 Reply)
Discussion started by: jamarsh
1 Replies

10. Red Hat

How to determine share name of Linux server?

Hi, How to determine share name of Linux server ? OS version is RHL 6.5 Regards, Maddy (11 Replies)
Discussion started by: Maddy123
11 Replies
KERNEL-INSTALL(8)						  kernel-install						 KERNEL-INSTALL(8)

NAME
kernel-install - Add and remove kernel and initramfs images to and from /boot SYNOPSIS
kernel-install COMMAND KERNEL-VERSION [KERNEL-IMAGE] DESCRIPTION
kernel-install is used to install and remove kernel and initramfs images to and from /boot. kernel-install will execute the files located in the directory /usr/lib/kernel/install.d/ and the local administration directory /etc/kernel/install.d/. All files are collectively sorted and executed in lexical order, regardless of the directory in which they live. However, files with identical filenames replace each other. Files in /etc/kernel/install.d/ take precedence over files with the same name in /usr/lib/kernel/install.d/. This can be used to override a system-supplied executables with a local file if needed; a symbolic link in /etc/kernel/install.d/ with the same name as an executable in /usr/lib/kernel/install.d/, pointing to /dev/null, disables the executable entirely. Executables must have the extension ".install"; other extensions are ignored. An executable should return 0 on success. It may also return 77 to cause the whole operation to terminate (executables later in lexical order will be skipped). COMMANDS
The following commands are understood: add KERNEL-VERSION KERNEL-IMAGE kernel-install creates the directory /boot/MACHINE-ID/KERNEL-VERSION/ and calls executables from /usr/lib/kernel/install.d/*.install and /etc/kernel/install.d/*.install with the arguments add KERNEL-VERSION /boot/MACHINE-ID/KERNEL-VERSION/ KERNEL-IMAGE The kernel-install plugin 50-depmod.install runs depmod for the KERNEL-VERSION. The kernel-install plugin 90-loaderentry.install copies KERNEL-IMAGE to /boot/MACHINE-ID/KERNEL-VERSION/linux. It also creates a boot loader entry according to the boot loader specification in /boot/loader/entries/MACHINE-ID-KERNEL-VERSION.conf. The title of the entry is the PRETTY_NAME parameter specified in /etc/os-release or /usr/lib/os-release (if the former is missing), or "Linux KERNEL-VERSION", if unset. If the file initrd is found next to the linux file, the initrd will be added to the configuration. remove KERNEL-VERSION Calls executables from /usr/lib/kernel/install.d/*.install and /etc/kernel/install.d/*.install with the arguments remove KERNEL-VERSION /boot/MACHINE-ID/KERNEL-VERSION/ kernel-install removes the entire directory /boot/MACHINE-ID/KERNEL-VERSION/ afterwards. The kernel-install plugin 90-loaderentry.install removes the file /boot/loader/entries/MACHINE-ID-KERNEL-VERSION.conf. EXIT STATUS
If every executable returns 0 or 77, 0 is returned, and a non-zero failure code otherwise. FILES
/usr/lib/kernel/install.d/*.install /etc/kernel/install.d/*.install Drop-in files which are executed by kernel-install. /etc/kernel/cmdline /proc/cmdline The content of the file /etc/kernel/cmdline specifies the kernel command line to use. If that file does not exist, /proc/cmdline is used. /etc/machine-id The content of the file specifies the machine identification MACHINE-ID. /etc/os-release /usr/lib/os-release The content of the file specifies the operating system title PRETTY_NAME. SEE ALSO
machine-id(5), os-release(5), Boot loader specification[1] NOTES
1. Boot loader specification https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec systemd 237 KERNEL-INSTALL(8)
All times are GMT -4. The time now is 03:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy