When connecting to a Linux server, we need to know the name of the running Linux distribution, its version number, and the kernel version number.
This is often done to determine:
- Commands for installing and updating software/packages (Package Management Tools): These commands vary from one distribution to another. For example, Debian and Ubuntu rely on the apt-get command, while CentOS and RedHat rely on the yum command.
- Commands to be used
- Versions of software/packages that we may install
These points vary from distribution to distribution and even from release to release.
You can use one of the following two methods to find out the name and version of the running distribution:
The first method to find out your current Linux distribution
The first method is to use the command:
cat /etc/*-release
Sample response for Ubuntu 12.04:
root@remote:~# cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"
Sample response for Debian 7:
root@remote:~# cat /etc/*-release
PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"
Sample response for CentOS 6.4:
[root@remote~]# cat /etc/*-release
CentOS release 6.4 (Final)
12.5.30 cos6.build1205150826.19
CentOS release 6.4 (Final)
CentOS release 6.4 (Final)
The second method to find your current Linux distribution
The second and less commonly used method is the command:
$ lsb_release -a
Sample response for Ubuntu 12.04:
root@remote:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04 LTS
Release: 12.04
Codename: precise
Finding the Linux Kernel Version
To find out your Linux kernel version, you can use the command:
$ uname -mrs
Some sample responses to the command:
Linux 2.6.32-042stab120.18
x86_64Linux 3.16.0-4-amd64 x86_64
Linux 3.13.0-55-generic x86_64
The information can be retrieved as follows:
- Kernel Name: Linux
- Kernel Version: 3.13.0-55-generic
- DeviceType : x86_64