Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 06-18-2002, 08:44 PM   #1
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.

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

Rep: Reputation: 47
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, 04:05 AM   #3
LQ Guru
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 234Reputation: 234Reputation: 234
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, 12:18 PM   #4
LQ Newbie
Registered: Jun 2002
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks Mik, trickykid.
Old 11-27-2009, 04: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, 02:57 PM   #6
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

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, 09:19 AM   #7
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Originally Posted by AhmadAboBakr View Post
the name of the distro can be fount in two files

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-30-2009, 12:14 AM   #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, 05:05 PM   #9
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:

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, 07:22 PM   #10
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,603
Blog Entries: 25

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Moderator Response


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.


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 03:54 PM
How tell what Linux distribution and version is running? johnkantor12 Linux - General 4 12-17-2007 12:35 PM
Find out distribution + version (NOT: kernel version!) Tajci Red Hat 5 06-08-2005 04:17 PM
How do I specify a version number to use? Seventh Linux - Newbie 1 08-26-2004 05:29 PM
Which Linux distribution and version to use for online SCM, CRM application? syseeker Linux - Newbie 1 02-04-2004 08:10 PM

All times are GMT -5. The time now is 02:05 AM.

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