How To Find Out My Linux Distribution Name and Version

How do I find out what version of Linux distribution I am using from the shell (bash) prompt? How can I tell my Linux distribution name and version?

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

ADVERTISEMENTS

a] /etc/*-release file.

Tutorial details
Difficulty Easy (rss)
Root privileges No
Requirements lsb_release
Time 2 minute
b] lsb_release command

c] /proc/version file.

d] hostnamectl command

Method 1. Use /etc/*-release file to display Linux distro version

To find out what version of Linux (distro) you are running, enter the following cat 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. Use lsb_release command To find out Linux distribution name and 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

Method 3. Use hostnamectl to find out my Linux distribution name and version

For GNU systemd based distro this is the best option:
$ hostnamectl

Find Out My Linux Distribution Name and Version

What version of Linux am I running?

How do I find out My Linux kernel version?

Type the following uname 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)

Here is output from my SUSE Enterprise Linux server:

What version of Linux distro and kernel am I running

Get Linux distribution name and version number in a shell

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

Another outputs from my CentOS 7 box:

Linux version 3.10.0-957.1.3.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Thu Nov 29 14:49:43 UTC 2018

And SUSE Enterprise Linux server:

Linux version 4.4.162-94.69-default (geeko@buildhost) (gcc version 4.8.5 (SUSE Linux) ) #1 SMP Mon Nov 5 18:58:52 UTC 2018 (9e06c56)

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

Conclusion

This page showed various commands to figure out what Linux kernel version and Linux distribution your server/desktop/laptop is running.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
63 comments… add one
  • nitin Nov 4, 2007 @ 16:07

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

    • vikash Mar 17, 2011 @ 12:13

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

      Thanks
      Vikash

    • Aleks Jan 18, 2014 @ 11:58

      For FreeBSD uname -a works OK

    • Damocles May 24, 2014 @ 1:03

      Well, the article was entitled “HowTo: Find Out My Linux Distribution Name and Version”… :-)

      Generally speaking, “uname -a” will tell you what you need to know. You may need to know a couple of quirks about the O.S. in question. For example, Solaris calls itself “SunOS” (long history there). AIX breaks the version number up into two different uname fields (“5 2” instead of “5.2” – it might even be “2 5” IIRC, which you then have to know to turn into “5.2”). Solaris has an /etc/release.

      If you’re going to use /etc/*-release, I would loose the dash

      cat /etc/*release

      as you’ll pick up a couple more flavors of Unix like that.

      “uname” was supposed to be the universal way to do this sort of thing, however, the output varies way too much from vendor to vendor.

      PS: Technically, Solaris is a “package deal” consisting of an operating system, an X-Windows package, etc. – 5 things that previously they had not bundled together. So, technically, Solaris 10 (for example) contains an operating system called SunOS 5.10. So when Solaris says “SunOS” in uname, it’s not really incorrect.

  • al Nov 6, 2007 @ 11:25

    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.

  • Richard Navarrete Mar 24, 2008 @ 17:48

    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

  • Kamal Sep 17, 2008 @ 14:12

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

  • Dennisq Quek Feb 5, 2009 @ 6:58

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

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

    • Damocles May 24, 2014 @ 0:51

      Well, that’s all fine well and good for home use, but security people will tell you announcing your o.s. and version in /etc/issue is a bad idea (why give hackers that info?). They will want you to replace /etc/issue with some kind of warning notification (“This computer is only for use by authorized employees of company X. Usage is subject to monitoring. All users are expected to comply with company security policy Y. Unauthorized use is subject is grounds for termination and/or criminal prosecution.”, etc.). Any computer owned by a company that has security people or lawyers, this isn’t going to work on. :-)

  • starioshka_Prokol Mar 16, 2009 @ 18:29

    thanx richy!!!it works

  • scottavian Oct 12, 2009 @ 23:04

    Thanks for the quick command. Worked perfectly.

  • maxx Jan 22, 2010 @ 3:45

    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!

  • gomathi Jan 22, 2010 @ 6:07

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

    • rude_ass Sep 23, 2011 @ 21:40

      would you also like a foot massage with that ??

      • ravi Sep 25, 2013 @ 4:11

        Ha ha.. Nice one Bro

  • Elambarithi Feb 9, 2010 @ 9:36

    Please specify the which Linux ? Redhat or else….

  • Daniel Feb 21, 2010 @ 13:42

    Also try

    uname -a

    • Raj Jan 8, 2013 @ 11:20

      Thanks Daniel, that helped on FreeBSD

  • Tibi Apr 9, 2010 @ 8:09

    Worked perfectly ;)

  • jamos Apr 13, 2010 @ 11:50

    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

  • takizo Sep 15, 2010 @ 8:11

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

  • Pietro Dec 4, 2010 @ 5:18

    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??

    • 🐧 nixCraft Dec 4, 2010 @ 12:14

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

      Both are different.

  • Roshan.Ahtina Dec 8, 2010 @ 9:18

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

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

  • tommed Dec 22, 2010 @ 10:15

    /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
    
  • Bhaskar Rimmalapudi Jan 27, 2011 @ 18:16

    This solution works perfect.

    uname -a

  • smarcell Feb 23, 2011 @ 17:18

    Also try:

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

    • R Oct 24, 2012 @ 13:47

      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

  • ravi Mar 29, 2011 @ 4:22

    thnx… helps lot

  • Bryce H. Apr 17, 2011 @ 10:05

    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.

    • Bryce H. Apr 17, 2011 @ 10:06

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

  • sams Apr 18, 2011 @ 11:51

    thank u .. it works

  • Atif Mehar Jun 2, 2011 @ 7:02

    Thanks, Its really a great tips

  • cm_R Jul 30, 2011 @ 16:31

    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.

  • prasanna Sep 5, 2011 @ 5:45

    please send me linux versions and release dates

  • jp Sep 20, 2011 @ 12:15

    hi

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

  • Betta Sep 26, 2011 @ 9:58

    Thanks a ton…
    lsb_release -a suited my requirements!

  • Carlos Santos Jan 24, 2012 @ 14:50

    Thanks :)

  • greg Apr 10, 2012 @ 7:06

    Same problem on Centos 5.6.

  • Landis Apr 25, 2012 @ 4:24

    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.

  • Mallesh May 26, 2012 @ 9:37

    Thanks Dear….. It helps me lot

  • Ali Sep 11, 2012 @ 14:21

    thanx a lot

  • ice Oct 8, 2012 @ 8:03

    thank you!
    It nice!

  • santosh Oct 8, 2012 @ 11:53

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

  • snehal Oct 9, 2012 @ 12:07

    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..

  • Sinclair J. Oct 25, 2012 @ 19:53

    Thanks :)

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

    • Matt F. Nov 23, 2012 @ 10:06

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

      yum install lsb
      lsb_release_a

  • bc Nov 5, 2012 @ 14:17

    command not found

  • hottetdf Mar 13, 2013 @ 10:44

    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.

  • Steve Apr 26, 2013 @ 15:01

    Useful info, easy to understand, thanks!

  • mariane Jul 27, 2013 @ 11:17

    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…

  • Vijay Kanta Sep 12, 2013 @ 8:03

    Superb, thanks again Vivek.

  • Marek Oct 22, 2013 @ 7:04

    Nice. Thank you :-)

  • Akila May 6, 2014 @ 3:53

    Thank you. Its very useful

  • Jeff Sep 26, 2014 @ 18:46

    This was so helpful, as was the adjacent discussion. Thanks!

  • Ganeshbabu Dec 17, 2014 @ 10:36

    Hi, i need to get the o.s. version of numbers of machines, how to writer the bash script to get the info…

  • ewinzkie Feb 24, 2015 @ 3:59

    thanks!!!

  • Pravin yadav Aug 6, 2015 @ 7:16

    Thanks Dear….. It helps me lot

  • Pravin yadav Aug 6, 2015 @ 7:17

    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..

  • Shamolkuece Aug 17, 2015 @ 19:54

    This is an important post.It is difficult to find out the version .but this post make it simple .At last i am successful in finding the my Linux distribution and version. Thanks a lot.

  • eric Jan 6, 2016 @ 22:01

    It is very instructive to see how distros vary from one another just by looking at solutions to the simple problem of finding out the distribution being used; it reveals how a given set of branches have made higher level decisions to optimize on this or that dimension. The variation is inspiring, actually.

  • daniel komis Nov 22, 2017 @ 18:51

    i am running deepin, and its based on debian, but doesnt show the version anywhere

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.