LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-16-2012, 03:47 AM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,129

Rep: Reputation: 30
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
 
Old 11-16-2012, 03:54 AM   #2
dragonix
Member
 
Registered: Nov 2012
Location: Belgium
Distribution: Ubuntu 12.04
Posts: 69
Blog Entries: 6

Rep: Reputation: 1
You can try this perhaps

Code:
cat /etc/issue
or
Code:
lsb_release -a
or
Code:
cat /proc/version
Use Google man

Last edited by dragonix; 11-16-2012 at 03:59 AM.
 
1 members found this post helpful.
Old 11-16-2012, 06:56 AM   #3
jmccue
Member
 
Registered: Nov 2008
Location: US
Distribution: slackware
Posts: 133

Rep: Reputation: 35
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
 
Old 11-16-2012, 08:47 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.

Last edited by theNbomr; 11-16-2012 at 08:49 AM.
 
Old 11-16-2012, 09:23 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,451
Blog Entries: 54

Rep: Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893
See for instance rkh_dat_get_os_info() (starting at line 5198 in that revision)? BTW this isn't exactly never asked before.
 
2 members found this post helpful.
Old 11-16-2012, 09:40 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
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
 
Old 11-16-2012, 11:02 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,451
Blog Entries: 54

Rep: Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893
Quote:
Originally Posted by catkin View Post
Maybe needs updating
Patches are welcome.
 
Old 03-21-2013, 10:31 AM   #8
ghostware
LQ Newbie
 
Registered: Jan 2013
Location: Alexandria, VA
Distribution: multiple
Posts: 3

Rep: Reputation: 0
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.

Last edited by ghostware; 03-21-2013 at 10:40 AM. Reason: Correction
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie Distro Question 1: Reasons for inter-distro pkg incompatibility. Wombat Pete Linux - Distributions 20 04-05-2010 01:59 PM
[rant] DIstro frustration and alienation/suggestions for stable distro Draciron Linux - Distributions 3 10-16-2009 10:27 AM
math distro....? music distro...? small distro....? jasonparent Linux - Newbie 11 02-11-2008 09:57 AM
How to convert a rpm based distro into deb (apt-get) distro ? pleasehelpme Linux - Newbie 3 02-11-2008 12:20 AM
LXer: DistroWatch Weekly: Distro hopping, Linux Format's distro mega-test LXer Syndicated Linux News 0 06-11-2007 04:47 AM


All times are GMT -5. The time now is 06:22 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration