How to know which Linux Distribution i am using ? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

How to know which Linux Distribution i am using ?

Shell Programming and Scripting


Tags
linux, solaris, ubuntu

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-02-2006
BasavarajaKC BasavarajaKC is offline
Registered User
 
Join Date: Jun 2006
Last Activity: 9 June 2006, 8:13 AM EDT
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
How to know which Linux Distribution i am using ?

Hi,

I m working on many Linux servers in my project. But i am unable to know which Linux Distribution i am using Like whether i am using SUSE or REDHAT or MONDRAKE. I tried with "uname" command. But it does not help me. Please provide me the command if u know.

Regards,
Basavaraja KC
Sponsored Links
    #2  
Old 06-02-2006
Jariya's Avatar
Jariya Jariya is offline
Registered User
 
Join Date: May 2005
Last Activity: 19 December 2007, 2:14 AM EST
Location: Madrid, Spain
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
have you typed "uname -a" ? i can see what darwin im using... :/
Sponsored Links
    #3  
Old 06-02-2006
BasavarajaKC BasavarajaKC is offline
Registered User
 
Join Date: Jun 2006
Last Activity: 9 June 2006, 8:13 AM EDT
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
already tried with uname -a

But its giving only "Linux", not which distribution of Linux.

Please any body help on this.
    #4  
Old 06-03-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Ex-Moderator
 
Join Date: Nov 2004
Last Activity: 16 December 2013, 12:55 AM EST
Location: Bahrain
Posts: 592
Thanks: 3
Thanked 8 Times in 3 Posts
try
Code:
cat /etc/issue

Following are the info files for different distributions:

Code:
Novell SuSE---> /etc/SuSE-release 
Red Hat--->/etc/redhat-release, /etc/redhat_version
Fedora-->/etc/fedora-release
Slackware--->/etc/slackware-release, /etc/slackware-version
Debian--->/etc/debian_release, /etc/debian_version
Mandrake--->/etc/mandrake-release
Yellow dog-->/etc/yellowdog-release
Sun JDS--->/etc/sun-release 
Solaris/Sparc--->/etc/release 
Gentoo--->/etc/gentoo-release

Regards,
Tayyab
Sponsored Links
    #5  
Old 06-07-2006
Jariya's Avatar
Jariya Jariya is offline
Registered User
 
Join Date: May 2005
Last Activity: 19 December 2007, 2:14 AM EST
Location: Madrid, Spain
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
An alternative way... i found by luck this file. here u can see the distribution but i dont know if its on all systems. At least its in Debian...

/proc/version

anyone ones if this file is a linux standard? because Darwin doesnt use /proc.
thx
Sponsored Links
    #6  
Old 07-04-2008
nobo nobo is offline
Registered User
 
Join Date: Jul 2008
Last Activity: 8 March 2012, 11:28 AM EST
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
whichNix

Found this old thread while researching. I come up against this problem often in a very heterogeneous network I admin. Barring us deploying Puppet or a similar solution (someday), I need a fix. There is no canonical way to determine distro so this script is a hack around. It works (gives a best guess) on slack, suse, rh, centOS, ubuntu, solaris, and a couple of other proprietary systems we use.

Comment, suggest, port, test, change, flame.

Code:
#! /bin/bash
# return an awkable string consisting of
#    unix OS type, or
#    Linux dist, or
#    a long guess (based on /proc), or
#    no clue

giveUp () {
   echo "Unknown"
   exit 0
}

# keep this easily awkable, prepending an initial clue
versionGuess () {
   if [ -e /proc/version ]; then
      echo -n "Unsure "
      cat /proc/version
      exit 0
   fi
   return 1
}

# if we have ignition, print and exit
gotDist () {
   [ -n "$1" ] && echo "$1" && exit 0
}

# we are only interested in a single word "dist" here
# various malformations can occur; admin will have to code appropately based on output
linuxRelease () {
   if [ -r /etc/lsb-release ]; then
      dist=$(grep 'DISTRIB_ID' /etc/lsb-release | sed 's/DISTRIB_ID=//' | head -1)
      gotDist "$dist"
   fi

   dist=$(find /etc/ -maxdepth 1 -name '*release' 2> /dev/null | sed 's/\/etc\///' | sed 's/-release//' | head -1)
   gotDist "$dist"

   dist=$(find /etc/ -maxdepth 1 -name '*version' 2> /dev/null | sed 's/\/etc\///' | sed 's/-version//' | head -1)
   gotDist "$dist"

   return 1
}

# start with uname and branch the decision from there
dist=$(uname -s 2> /dev/null)
if [ "$dist" = "Linux" ]; then
   linuxRelease
   versionGuess
   giveUp
elif [ -n "$dist" ]; then
   echo "$dist"
   exit 0
else
   versionGuess
   giveUp
fi

# we shouldn't get here
giveUp
# done

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
What was your first Linux distribution? billcrosby What is on Your Mind? 32 12-05-2012 08:37 AM
Which Linux distribution has a GUI like MS Windows ? gentleDean Linux 4 11-30-2009 05:09 AM
Linux Distribution Phi01 Programming 4 02-28-2009 12:55 PM
What Linux distribution should I use? Sixmax UNIX for Dummies Questions & Answers 7 05-28-2008 01:27 AM
How to know which Linux Distribution i am using BasavarajaKC UNIX for Dummies Questions & Answers 3 06-02-2006 08:00 AM



All times are GMT -4. The time now is 06:25 PM.