How to check OS version in Linux?


The command to check OS version in RedHat, CentOS and Fedora are:
Code:
cat /etc/redhat-release

Example:
Code:
[admin@devopsrun1 ~]$ cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
This works on regular servers, virtual machines, and Docker containers.

Other Linux/Unix based Operating systems


All other Linux/Unix Operating systems(such as Ubuntu, AmazonLinux etc), the command cat /etc/os-release should give the OS version.
Code:
[admin@devopsrun1 ~]$ cat /etc/os-release
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"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

Alternate way


For all other popular Linux/Unix distributions, the following command should work
Code:
cat /etc/*-release
Let me know if you have any questions...