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