Skip to content

How To Figure Out What Distribution & Version Of Linux Is Installed and Running

I’ve often found myself picking up on a server build, taking over administration, or troubleshooting problems on Linux based OS’s, with absolutely no clue as to what distribution of Linux is running on said machine. The distribution dictates what package manager is used, such as yum for CentOS / RHEL, and apt (aptitude) for Debian and Ubuntu based distributions. So, if you’re working on a Linux machine and you want to figure out exactly what you’re working with, there are some basic commands you can run that will tell you precisely that.

To find out what distribution is installed

There is always a file in /etc called something-release. This file will give you the basic info you need. So, using cat, we can figure out exactly what distribution is installed by running this.

#  cat /etc/*-release

Here is an example of what you can expect to see on an Ubuntu 14.04 server.

Screen Shot 2015-05-16 at 12.48.13 PM

As you can see, this gives you quite a bit of information to work with. All the way down to the release version and codename designation, as well as the root os base, which is Debian in the case of Ubuntu. Now, lets see what this looks like on another distribution, such as CentOS.


Screen Shot 2015-05-16 at 12.49.21 PM

Here, you can see that this server is running CentOS 7.1. It’s also worth noticing that there is usually a link to the homepage of the distribution. This could come in handy if you’re working with an obscure distribution you’ve never worked with or heard of before.

Now, this isn’t the only way to get this information. It can also be obtained by using the lsb_release command.

To get distribution info using lsb_release

#  lsb_release -a

This command will give you a little less information, but everything you need in most cases. Here is what you can expect to see when you run this on Ubuntu.

Screen Shot 2015-05-16 at 12.49.02 PM

From my experience, lsb_release only works on Debian based distributions. So, it will not work on CentOS. If you only want to get the kernal version, hostname, and see if you’re using a 32bit or 64bit platform, you can use the uname command. This command works on all linux distributions, however, it does not provide you with the distribution name.

#  uname -a

Here is what this looks like on Ubuntu.

Screen Shot 2015-05-16 at 12.48.41 PM

and CentOS

[[email protected] ~]# uname -a
Linux hostname.domainname.com 3.10.0-229.1.2.el7.x86_64 #1 SMP Fri Mar 27 03:04:26 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Using this information, you should be able to extract all of the necessary info from a linux workstation or server. If you have any questions, feel free to ask in the comments below. Thanks!