Find out my Linux Distribution Name and Version
This blog shows you how to find out Linux distributions and version you are running. How can I tell my Linux distribution name and version?
You can use any one of the following method to find out your Linux distribution and name:
1. Use /etc/*-release file
To find out what version of Linux (distro) you are running, enter the following cat command at the shell prompt:
$ cat /etc/*-release
Sample outputs from CentOS 7.6.1810 server
CentOS Linux release 7.6.1810 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
CentOS Linux release 7.6.1810 (Core)
Sample output from my RHEL v5.x server
Red Hat Enterprise Linux Server release 5 (Tikanga)
Sample outputs from my Ubuntu Linux v7.10 server
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=7.10
DISTRIB_CODENAME=gutsy
DISTRIB_DESCRIPTION="Ubuntu 7.10"
2. lsb_release command
The lsb_release command displays certain LSB (Linux Standard Base) and distribution-specific information. Type the following command:
LSB is followed only by few Linux distributions like Ubunutu, RHEL, Debian, SUSE Linux and few more.
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 6.0.1 (squeeze)
Release: 6.0.1
Codename: squeeze
3. hostnamectl command
For GNU systemd based distro this is the best option:
$ hostnamectl
4. /proc/version file.
Get kernel and gcc version
Execute following command to see kernel version and gcc version used to build the same:
$ cat /proc/version
Sample output from CentOS 7.6.1810 server
Linux version 4.9.125-linuxkit (root@659b6d51c354) (gcc version 6.4.0 (Alpine 6.4.0) ) #1 SMP Fri Sep 7 08:20:28 UTC 2018
Get Linux kernel version
Type the following uname command
$ uname -a
or
$ uname -mrs
Sample output from CentOS:
Linux 4.9.125-linuxkit x86_64
Where:
- Linux – Kernel name
- 4.9.125-linuxkit – Kernel version number
- x86_64 – Machine hardware name (64 bit)