How to know exactly which Linux distribution you are using

I myself usually have to connect to a lot of Linux server to troubleshot. As you know, different Linux distribution has different config file location. For example, Apache config file in CentOS server is /etc/httpd/httpd.conf but in Ubuntu/Debian is /etc/apache2/apache2.conf

It would be easier for us if we know exactly the distribution name from the beginning. Here are several solutions:

1. From the boot time message

dmesg | head -1

You might see something like this:

Linux version 2.6.31-14-generic ([email protected]) (gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8) ) #48-Ubuntu SMP Fri Oct 16 14:05:01 UTC 2009

2. Using /proc/version

cat /proc/version

You might see something like this:

Linux version 2.6.31-14-generic ([email protected]) (gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8) ) #48-Ubuntu SMP Fri Oct 16 14:05:01 UTC 2009

3. Using /etc/issue

cat /etc/issue

You might see something like this:

Debian GNU/Linux 6.0 \n \l

4. Using /etc/*-release

cat /etc/*-release

You might see something like this:

Gentoo Base System release 1.12.9

Disclaimer: The results are different because I’m using different machine when testing. have fun :)