How To Find Out Your Current Linux Distribution

Mattias Geniar, Sunday, October 5, 2008 - last modified: Sunday, February 19, 2012

With so many distributions of Linux out there, and each having its own method of identifying itself, it can get tricky to find out the Linux version you're working on.

You can usually find out most of the information in the /etc/*release or /etc/*version files. If any of those files exist, you can cat them to find out its content -- and to find out which distribution you're running.

Here are a couple of examples.

Debian-based

localhost:~# cat /etc/debian_version 
4.0

Red Hat based

[root@vps /]# cat /etc/redhat-release 
CentOS release 5.2 (Final)

Fedora based

localhost:~# cat /etc/fedora-release
....

Of course you see a trend happening here -- it's always in some "*-release" or "*_version"-file.  You can shorten it as follows.

[root@vps /]# cat /etc/*-release 
CentOS release 5.2 (Final)

That way, you don't have to manually try out every option. You can use a "cat /etc/*_version" look-a-like to identify debian based distributions.

You can find a very complete list of files where to identify your current Linux version, at the LinuxMafia.com website -- release files.

You can also use one of the following tricks, to get your needed data -- should the above one not work.

[root@vps ~]# cat /etc/issue
CentOS release 5.2 (Final)
Kernel \r on an \m

[root@vps ~]# cat /proc/version 
Linux version 2.6.18-028stab053.17-ent (root@rhel5-32-build) (gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)) #1 SMP Mon Jun 9 22:08:38 MSD 2008

And to find out your current kernel, you can use "uname" as follows.

[root@vps ~]# uname -a
Linux [servername] 2.6.18-028stab053.17-ent #1 SMP [date] i686 i686 i386 GNU/Linux


Hi! My name is Mattias Geniar. I'm a Support Manager at Nucleus Hosting in Belgium, a general web geek & public speaker. Currently working on DNS Spy & Oh Dear!. Follow me on Twitter as @mattiasgeniar.


Share this post

Did you like this post? Will you help me share it on social media? Thanks!

Comments

Johan Tuesday, October 7, 2008 at 08:13 - Reply

lsb_release -a can help to


Leave a Reply

Your email address will not be published. Required fields are marked *

Inbound links