Posted By

micmath on 07/27/07


Tagged

linux


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

mabridge
sbbath
funkmyer


What linux distro is this?


 / Published in: Bash
 

From http://www.novell.com/coolsolutions/feature/11251.html

  1. try this:
  2. cat /etc/issue
  3.  
  4. or run this:
  5. #!/bin/sh
  6. # Detects which OS and if it is Linux then it will detect which Linux Distribution.
  7.  
  8. OS=`uname -s`
  9. REV=`uname -r`
  10. MACH=`uname -m`
  11.  
  12. GetVersionFromFile()
  13. {
  14. VERSION=`cat $1 | tr "\n" ' ' | sed s/.*VERSION.*=\ // `
  15. }
  16.  
  17. if [ "${OS}" = "SunOS" ] ; then
  18. OS=Solaris
  19. ARCH=`uname -p`
  20. OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
  21. elif [ "${OS}" = "AIX" ] ; then
  22. OSSTR="${OS} `oslevel` (`oslevel -r`)"
  23. elif [ "${OS}" = "Linux" ] ; then
  24. KERNEL=`uname -r`
  25. if [ -f /etc/redhat-release ] ; then
  26. DIST='RedHat'
  27. PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
  28. REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
  29. elif [ -f /etc/SuSE-release ] ; then
  30. DIST=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
  31. REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
  32. elif [ -f /etc/mandrake-release ] ; then
  33. DIST='Mandrake'
  34. PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
  35. REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
  36. elif [ -f /etc/debian_version ] ; then
  37. DIST="Debian `cat /etc/debian_version`"
  38. REV=""
  39.  
  40. fi
  41. if [ -f /etc/UnitedLinux-release ] ; then
  42. DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
  43. fi
  44.  
  45. OSSTR="${OS} ${DIST} ${REV}(${PSUEDONAME} ${KERNEL} ${MACH})"
  46.  
  47. fi
  48.  
  49.  
  50. echo ${OSSTR}

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: micmath on July 27, 2007

an even more complete solution can be found [here] (http://moustix.dyndns.org/fred/index.php/2006/06/17/5-script-to-return-the-linux-distribution-version-and-architecture)

You need to login to post a comment.