LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 06-18-2002, 07:44 PM   #1
s&j
LQ Newbie
 
Registered: Jun 2002
Posts: 6

Rep: Reputation: 0
Question Getting the Linux Distribution Name and Version Number


I want to write a script that can run on all the different Linux Distributions (Mandrake, Red Hat, Debian, SuSE, Slackware, Lycoris....) and will print for me the name of the Linux Distribution and its version. The output of the script will be something like: "This machine runs Red Hat Linux Version 7.2" or "This machine runs Mandrake Linux Version 8.2"...

I tried using the uname command but that gives only the kernel version number and does not give the name of the distribution. I tried a number of ways to get the information (for example in case of Red Hat there is a file /etc/redhat-release that contains this information) but could not find a general way that will work on all the distributions.

Is there a way to do this ? Any suggestions will be of great help.

Thanks.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 06-19-2002, 02:28 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 46
There isn't really any standard way common to all distributions. If you want that information you will have to get it from the /etc/<distro>-release file. Not sure if all distributions do that though.
I know redhat, mandrake and suse do though. Just test for the presence of the different files. I've got an LFS system and the only way to recognize that is because I did a touch /etc/lfs-<version> like the book suggests. But I guess there would be a million more ways to identify a certain system.
 
Old 06-19-2002, 03:05 AM   #3
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
in most cases use the -a flag with the uname option for all information.

uname -a

but other than that, yeah, most distro's have a version file like Mik said, Slackware has this file too.
 
Old 06-19-2002, 11:18 AM   #4
s&j
LQ Newbie
 
Registered: Jun 2002
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks Mik, trickykid.
 
Old 11-27-2009, 03:43 AM   #5
Dr Belka
LQ Newbie
 
Registered: Jun 2009
Location: Atlanta, Georgia
Distribution: Ubuntu 9.04
Posts: 6

Rep: Reputation: 0
I hate to dig up a really really old thread, but... I was wondering how exactly uname goes about finding the name of a distro. In my case, I would like to make my own "distro" customized from the live cd of Ubuntu. I would like uname -s and uname -o to print the name of my distro instead of "Ubuntu"

Also, on a slightly unrelated note, I was wondering if this change would affect the way grub recognized the name of the distro. what I mean by that is... When I install GRUB on a computer that already has a linux distro on it, it normally will correctly identify the name and version of the distro and add it to it's menu.lst. I am wondering how GRUB goes about doing this.
 
Old 11-28-2009, 01:57 PM   #6
AhmadAboBakr
LQ Newbie
 
Registered: Nov 2009
Location: Egypt
Distribution: Debian
Posts: 2

Rep: Reputation: 0
the name of the distro can be fount in two files

Code:
/etc/lsb-release
and
Code:
/etc/issue
but I don't recommend changing them cause that would make some apps stop working
like ubuntu-tweak for example which dose different tasks to each version and if your version is not recognized some functions will not work
 
1 members found this post helpful.
Old 11-29-2009, 08:19 AM   #7
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
Quote:
Originally Posted by AhmadAboBakr View Post
the name of the distro can be fount in two files

Code:
/etc/lsb-release
and
Code:
/etc/issue
That is correct for many distros but not for all.

The shell script function in this LQ post may help.

There is a more complete list of /etc/*[-_]release files here.
 
2 members found this post helpful.
Old 11-29-2009, 11:14 PM   #8
Dr Belka
LQ Newbie
 
Registered: Jun 2009
Location: Atlanta, Georgia
Distribution: Ubuntu 9.04
Posts: 6

Rep: Reputation: 0
thank you. My question is answered
 
Old 08-12-2012, 04:05 PM   #9
leosubhadeep
Member
 
Registered: Jul 2012
Location: West Bengal,India
Distribution: Ubuntu 14.04,Fedora 20,Windows 7
Posts: 111
Blog Entries: 3

Rep: Reputation: 1
Thumbs up

This thread is quite old, and I found it while googling.
I have found a link: http://www.cyberciti.biz/faq/find-li...ersion-number/

It provides the simple shell commands to find about distros. But I think I'm too late to post this link in this thread!
 
Old 08-12-2012, 06:22 PM   #10
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 11,281
Blog Entries: 3

Rep: Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446
Moderator Response

Hi,

Yes, the thread is quite old. Since you did contribute in a positive constructive sense then I will politely add: Please do not resurrect necro(dead) threads.
 
1 members found this post helpful.
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding distribution + kernel version + gcc version + glib version. JCipriani Linux - General 8 04-19-2008 02:54 PM
How tell what Linux distribution and version is running? johnkantor12 Linux - General 4 12-17-2007 11:35 AM
Find out distribution + version (NOT: kernel version!) Tajci Red Hat 5 06-08-2005 03:17 PM
How do I specify a version number to use? Seventh Linux - Newbie 1 08-26-2004 04:29 PM
Which Linux distribution and version to use for online SCM, CRM application? syseeker Linux - Newbie 1 02-04-2004 07:10 PM


All times are GMT -5. The time now is 08:35 AM.

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