How To Find Out Your Current Linux Distribution

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, October 05, 2008

Follow me on Twitter as @mattiasgeniar

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


Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.