LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to know what distro is it (http://www.linuxquestions.org/questions/linux-newbie-8/how-to-know-what-distro-is-it-4175437404/)

ust 11-16-2012 04:47 AM

How to know what distro is it
 
I have a linux server , I check the /etc/ , there is no *release* file in it , can advise how can I know what linux distro is it ? eg. CentOS , suse

dragonix 11-16-2012 04:54 AM

You can try this perhaps

Code:

cat /etc/issue
or
Code:

lsb_release -a
or
Code:

cat /proc/version
Use Google man ;)

jmccue 11-16-2012 07:56 AM

Also try looking for a file like:
/etc/*-version
Also seems newer releases of some distros are starting to use a file named:
/etc/os-release

John

theNbomr 11-16-2012 09:47 AM

You can sometimes get a clue from distro names encoded in the kernel name:
Code:

uname -a
Linux myHostName 2.6.18-164.10.1.el5 #1 SMP Thu Jan 7 22:25:39 EST 2010 i686 i686 i386 GNU/Linux

indicates a kernel for 'Enterprise Linux 5', which is a Redhat based kernel & distro.

--- rod.

unSpawn 11-16-2012 10:23 AM

See for instance rkh_dat_get_os_info() (starting at line 5198 in that revision)? BTW this isn't exactly never asked before.

catkin 11-16-2012 10:40 AM

Maybe needs updating but
Code:

function get_distro_name {
    if [[ -r '/etc/lsb-release' ]]; then
        . /etc/lsb-release
        [[ "$DISTRIB_ID" ]] && n="$DISTRIB_ID"
    elif [[ -r '/etc/release' ]]; then
        n=`head -1 /etc/release | sed 's/ *\([[^0-9]]*\) [0-9].*/\1/'`
    elif [[ -r '/etc/arch-release' ]]; then
        n="Arch Linux"
    elif [[ -r '/etc/debian_version' ]]; then
        n='Debian'
    elif [[ -r '/etc/gentoo-release' ]]; then
        n='Gentoo'
    elif [[ -r '/etc/knoppix-version' ]]; then
        n='Knoppix'
    elif [[ -r '/etc/mandrake-release' ]]; then
            n='Mandrake'
    elif [[ -r '/etc/pardus-release' ]]; then
        n='Pardus'
    elif [[ -r '/etc/puppyversion' ]]; then
        n='Puppy Linux'
    elif [[ -r '/etc/redhat-release' ]]; then
        n='Red Hat'
    elif [[ -r '/etc/slackware-version' ]]; then
        n='Slackware'
    elif [[ -r '/etc/SuSE-release' ]]; then
        n='SuSE'
    elif [[ -r '/etc/xandros-desktop-version' ]]; then
        n='Xandros'
    elif [[ -r '/etc/zenwalk-version' ]]; then
        n="Zenwalk"
    fi
    [[ $n = '' ]] &&  echo "ERROR: Could not determine the distro name" >&2
} # get_distro_name


unSpawn 11-16-2012 12:02 PM

Quote:

Originally Posted by catkin (Post 4830823)
Maybe needs updating

Patches are welcome.

ghostware 03-21-2013 11:31 AM

Thanks for effort.

For SuSE it has both a /etc/lsb-release and a /etc/SuSE-release file.
However there is no DISTRIB_ID value set in the file so value n never gets set.

I'd suggest putting the /etc/lsb-release as part of else clause and have variable n overrided if DISTRIB_ID variable is set.


All times are GMT -5. The time now is 08:18 PM.