HowTo: Find Out My Linux Distribution Name and Version

by on October 25, 2007 · 51 comments· LAST UPDATED December 29, 2013

in , ,

How do I find out what version of Linux distribution I'm using from the shell (bash) prompt?

You can use any one of the following method to find out your Linux distribution and name:

a] /etc/*-release file.

Tutorial details
DifficultyEasy (rss)
Root privilegesNo
Requirementslsb_release
Estimated completion time2 minute
b] lsb_release command.

c] /proc/version file.

Method #1: /etc/*-release file

To find out what version of Linux (distro) you are running, enter the following command at the shell prompt:
$ cat /etc/*-release
Sample output from my RHEL v5.x server:

Red Hat Enterprise Linux Server release 5 (Tikanga)
Sample outputs from my Ubuntu Linux v7.10 server:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=7.10
DISTRIB_CODENAME=gutsy
DISTRIB_DESCRIPTION="Ubuntu 7.10"

Method #2: lsb_release Command To Find Out Linux Distribution Name/Version

The lsb_release command displays certain LSB (Linux Standard Base) and distribution-specific information. Type the following command:
$ lsb_release -a
Sample outputs:

No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 6.0.1 (squeeze)
Release:	6.0.1
Codename:	squeeze

How Do I Find Out My Kernel Version?

Type the following command:
$ uname -a
OR
$ uname -mrs
Sample outputs:

Linux 2.6.32-5-amd64 x86_64

Where,

  1. Linux - Kernel name
  2. 2.6.32-5-amd64 - Kernel version number
  3. x86_64 - Machine hardware name (64 bit)

Say hello to /proc/version

Type the following command to see kernel version and gcc version used to build the same:
$ cat /proc/version
Sample outputs:

Linux version 3.2.0-0.bpo.1-amd64 (Debian 3.2.4-1~bpo60+1) (ben@decadent.org.uk) (gcc version 4.4.5 (Debian 4.4.5-8) ) #1 SMP Sat Feb 11 08:41:32 UTC 2012

Related media

This tutorial is also available in a quick video format:



Video 01: Find The Linux Kernel Version Command Tutorial

Putting It All Together

Animated gif.01: Finding out Linux distribution name and version with various commands demo

Animated gif.01: Finding out Linux distribution name and version with various commands demo

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 51 comments… read them below or add one }

1 nitin November 4, 2007 at 4:07 pm

But how to find version of other unix systems like FreeBSD. cat /etc/*-release won’t give it

Reply

2 vikash March 17, 2011 at 12:13 pm

Thanks for giving command cat /etc/*-release
Really this is useful

Thanks
Vikash

Reply

3 Aleks January 18, 2014 at 11:58 am

For FreeBSD uname -a works OK

Reply

4 al November 6, 2007 at 11:25 am

This isn’t exactly a general solution. It assumes the distribution supports some LSB stuff, I think.
For debian and slackware, one could try:

$ cat /etc/*version

On debian stable, lsb-release exists, but just isn’t in /etc/. There is an lsb-release package, and you can run:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 4.0r1 (etch)
Release: 4.0r1
Codename: etch

By the way, lsb_release -a also works on the older Ubuntu version I have.

Reply

5 Richard Navarrete March 24, 2008 at 5:48 pm

You can also cat version in proc…


:; cd /proc
;; cat version
Linux version 2.6.9-42.0.3.ELsmp (brewbuilder@hs20-bc1-7.build.redhat.com) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)) #1 SMP Mon Sep 25 17:28:02 EDT 2006

Reply

6 Kamal September 17, 2008 at 2:12 pm

Thanks Richard,
cat /proc/version worked for me..

Reply

7 Dennisq Quek February 5, 2009 at 6:58 am

Thanks alot ! all commands gave some good info about my sys.

And “cat /etc/issue” as well, for my ubuntu 8

Reply

8 starioshka_Prokol March 16, 2009 at 6:29 pm

thanx richy!!!it works

Reply

9 scottavian October 12, 2009 at 11:04 pm

Thanks for the quick command. Worked perfectly.

Reply

10 maxx January 22, 2010 at 3:45 am

hi guys,
can this kind of file which contains the version info be modified? for example when I want to remaster Ubuntu to new name with my name: Maxx

do we just to modify a file? or what should we do?

thanks in advance!

Reply

11 gomathi January 22, 2010 at 6:07 am

hai ,
i read ur information for linux.but, i want “what r the different versions available in linux”.please give ans immediately

Reply

12 rude_ass September 23, 2011 at 9:40 pm

would you also like a foot massage with that ??

Reply

13 ravi September 25, 2013 at 4:11 am

Ha ha.. Nice one Bro

Reply

14 Elambarithi February 9, 2010 at 9:36 am

Please specify the which Linux ? Redhat or else….

Reply

15 Daniel February 21, 2010 at 1:42 pm

Also try

uname -a

Reply

16 Raj January 8, 2013 at 11:20 am

Thanks Daniel, that helped on FreeBSD

Reply

17 Tibi April 9, 2010 at 8:09 am

Worked perfectly ;)

Reply

18 jamos April 13, 2010 at 11:50 am

Hi Daniel, I think your solution will only give the hostname, Kernel, arhitecture etc, but NOT the “distribution name” as is quoted on the question. Havent checked on anyother distro, but at least thats what happens on my CentOS 5.4, the other solutions seem to work.


[root@myhostname ~]# uname -a
Linux myhostname.mydomanin.com 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux

Reply

19 takizo September 15, 2010 at 8:11 am

Thanks. Was digging few old linux machines and found this works. Running very old ubuntu ;)

Reply

20 Pietro December 4, 2010 at 5:18 am

I’m on rhel .. if I type cat /etc/*release I get:
Red Hat Enterprise Linux WS release 4 (Nahant Update 3)

but if I type cat /proc/version I get:
Linux version 2.6.9-34.0.1.EL.ADSKsmp (root@oka) (gcc version 3.4.4 20050721 (Red Hat 3.4.4-2))

I’m confused :( so what’s my distribution??

Reply

21 nixCraft December 4, 2010 at 12:14 pm

Your distribution is RHEL and your kernel version is 2.6.9-34.0.1.

Both are different.

Reply

22 Roshan.Ahtina December 8, 2010 at 9:18 am

hi guys
please tyr
FOR UNIX:
#cat /etc/issue
#cat /etc/*-release
#cat /proc/version
#uname -a

FOR Debai/slackware:
#cat /etc/*version

Reply

23 tommed December 22, 2010 at 10:15 am

/etc/issue works for Debian too! I use something like this:

if [ "`cat /etc/issue | grep Debian | wc -l`" == "1" ]; then
    echo "is debian"
else
   cat /etc/issue # write out distro name

Reply

24 Bhaskar Rimmalapudi January 27, 2011 at 6:16 pm

This solution works perfect.

uname -a

Reply

25 smarcell February 23, 2011 at 5:18 pm

Also try:

$ cat /etc/[A-Za-z]*[_-][rv]e[lr]*

Reply

26 R October 24, 2012 at 1:47 pm

Hi!

Nice example!
Anyhow I can not see why needed the [A-Za-z] part. Please let me know.
So here are the roots of a brand new all platformer ver.sh one-liner…. B-)

cd /etc && cat *_ver* *-rel* /proc/version && uname -a && lsb_release -a

Let us know what does it miss?? (I know – this must be considered as pre-alpha version. B-) some file and command availability should be implemented…)

…. OK – sorry for the OT-like summary here.

R

Reply

27 ravi March 29, 2011 at 4:22 am

thnx… helps lot

Reply

28 Bryce H. April 17, 2011 at 10:05 am

I typed this in and it worked: cat /proc/version

And this came up : Linux version 2.6.34houkouonchi-web100-ioat-vlan (root@houkouonchi) (gcc version 4.1.2 (Gentoo 4.1.2)) #1 SMP Thu Oct 14 16:27:09 PDT 2010

What distro would this be??? I am running my linux through a data center that I have access to.

Reply

29 Bryce H. April 17, 2011 at 10:06 am

Oh it would be Gentoo. THANKS! answered my own question =P

Reply

30 sams April 18, 2011 at 11:51 am

thank u .. it works

Reply

31 Atif Mehar June 2, 2011 at 7:02 am

Thanks, Its really a great tips

Reply

32 cm_R July 30, 2011 at 4:31 pm

smarcell – you are so clever. I am in awe.

but when I type that into the little white box thing, it just says “cat /etc/lsb-release.d: Is a directory”

and I still have no idea what my OS is ;-P

more seriously:

maxx – no you don’t want to change these files or try; what you want to do is something like (just an e.g.) in

/etc/rc.local
#!/bin/sh
#other stuff will be here probably, put your stuff at the end

echo “Hello, you’ve just successfully gained access to Maxx’s computer” > /etc/motd
cat /proc/version >> /etc/motd
echo `uname -a` >> /etc/motd

and so on. you are printing text and the output of programs to the file /etc/motd using shell syntax (the little backticks mean “interpret as a command to run” and echo means “print this” and > means “create a file and send this to it” and “>> means append this to the end of this file”

generally, motd will be printed on login (“message of the day”, quite old school, some systems might not have it I guess. My Scientific Linux 6.1 does. I think ubuntu does. maybe not.)

if not, you can make it yourself and have it in everyone’s .bashrc by editing /etc/skel. For that matter you can put anything you want in .bashrc or .profile and it will run whevever a shell is opened (a bash shell obviously).

/proc isn’t usually somewhere you want to write, unless you know why you are doing it.

Reply

33 prasanna September 5, 2011 at 5:45 am

please send me linux versions and release dates

Reply

34 jp September 20, 2011 at 12:15 pm

hi

thank you for cat /etc/*-release
and lsb_release -a
very helpful

Reply

35 Betta September 26, 2011 at 9:58 am

Thanks a ton…
lsb_release -a suited my requirements!

Reply

36 Carlos Santos January 24, 2012 at 2:50 pm

Thanks :)

Reply

37 greg April 10, 2012 at 7:06 am

Same problem on Centos 5.6.

Reply

38 Landis April 25, 2012 at 4:24 am

Thank you all! Спасибо,
You’d think ‘displaying kernel version number’ would be a simple, everyday command to find… I’m sure most of you know, that is not true. I search and check a hundred pages before finding this article. I should have now to check nixCraft (cyberciti) first or at lest in the top 5 sites..

Learning.
Thanks again.
Landis.

Reply

39 Mallesh May 26, 2012 at 9:37 am

Thanks Dear….. It helps me lot

Reply

40 Ali September 11, 2012 at 2:21 pm

thanx a lot

Reply

41 ice October 8, 2012 at 8:03 am

thank you!
It nice!

Reply

42 santosh October 8, 2012 at 11:53 am

I wish to update my linux distro…can you post the commands please..

Reply

43 snehal October 9, 2012 at 12:07 pm

i have linux RH 5, it shows kernal version some 2.6 and server version also 2.6
so which is my linux version or how can i check it..

Reply

44 Sinclair J. October 25, 2012 at 7:53 pm

Thanks :)

lsb_release -a => this command not work for me.
Which linux distribution support this command.
currently I have centOS

Reply

45 Matt F. November 23, 2012 at 10:06 am

lsb_release isn’t installed on CentOS by default. just install it.

yum install lsb
lsb_release_a

Reply

46 bc November 5, 2012 at 2:17 pm

command not found

Reply

47 hottetdf March 13, 2013 at 10:44 am

hi folks,

just fell into this thread, verified it and … got confused.
Well, my CentOS just updated from 6.3 to 6.4. Everything I verified showed up 6.4, except /etc/issue, which still contains 6.3. So my conclusion is, that this file is created at install time and may be left untouched by updates. And yes, /etc/issue can safely be ‘personalized’, ‘taylored’ or whatever you like to call such customizing.

So far just my few cents.

Reply

48 Steve April 26, 2013 at 3:01 pm

Useful info, easy to understand, thanks!

Reply

49 mariane July 27, 2013 at 11:17 am

Didn’t work for me. I’ve got a weird environment which does not know “cat” (nor a lot of other stuff, like “more” and “nano”). It does not even understand “man”! It says: “Invalid command”.
It understands “cd” and “ls”. So far that’s about it.

All I can tell is that it’s not bash. I would like to find out what I’m talking to in order to look up the relevant vocabulary…

If it’s any clue, I could not connect via ftp. When I tried ssh it told me to use sftp and closed the connection. Now I’m talking to it via sftp but getting nowhere…

Reply

50 Vijay Kanta September 12, 2013 at 8:03 am

Superb, thanks again Vivek.

Reply

51 Marek October 22, 2013 at 7:04 am

Nice. Thank you :-)

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: