What linux distro is this?


/ Published in: Bash
Save to your folder(s)

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


Copy this code and paste it in your 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

You need to login to post a comment.