There are many Linux distributions out there, all with their slight differences. It’s sometimes its hard to determine what distribution you are current using, assuming you weren’t the one who installed it. The commands below can be used to determine the Linux distribution you are using, and in most cases, what version.
Generic check:
cat /etc/issue.net
or
cat /etc/issue
Sample output:
# cat /etc/issue.net CentOS release 6.3 (Final) Kernel \r on an \m #
This shows that the distribution is CentOS, and its version 6.3.
This will work for most distributions that show the distribution name and version number at the login prompt.
Another generic check:
$ cat /etc/*release*
Example:
# cat /etc/*release* CentOS release 6.3 (Final) CentOS release 6.3 (Final) CentOS release 6.3 (Final) cpe:/o:centos:linux:6:GA #
Ubuntu specific:
If you know its a Ubuntu distribution, but aren’t sure what version, you can use the following command:
$ lsb_release -a
Example output:
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 10.04.4 LTS Release: 10.04 Codename: lucid $
CentOS specific:
# cat /etc/centos-release
Example output:
# cat /etc/centos-release CentOS release 6.3 (Final) #