This post will guide you how to find out what version of RHEL or CentOS am I using at the shell prompt from the command line. How to check your RHEL or CentOS Linux system version from the command line.
You can use one of the following command to get the version of your CentOS or RHEL Linux system:
$ lsb_release $ cat /etc/redhat-release $ cat /etc/centos-release $ cat /etc/issue $ cat /etc/os-release $ hostnamectl
Outputs:
[devops@mydevops ~]$ cat /etc/redhat-release CentOS Linux release 8.0.1905 (Core) [devops@mydevops ~]$ cat /etc/centos-release CentOS Linux release 8.0.1905 (Core) [devops@mydevops ~]$ cat /etc/issue \S Kernel \r on an \m [devops@mydevops ~]$ cat /etc/os-release NAME="CentOS Linux" VERSION="8 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="8" PLATFORM_ID="platform:el8" PRETTY_NAME="CentOS Linux 8 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:8" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-8" CENTOS_MANTISBT_PROJECT_VERSION="8" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="8" [devops@mydevops ~]$ hostnamectl Static hostname: mydevops.com Icon name: computer-vm Chassis: vm Machine ID: 64546461ac834752ba28f56897c82278 Boot ID: 6bb93c981f9342f2abc8ac933da00b25 Virtualization: oracle Operating System: CentOS Linux 8 (Core) CPE OS Name: cpe:/o:centos:centos:8 Kernel: Linux 4.18.0-80.el8.x86_64 Architecture: x86-64
If you want to use lsb_release command to display the version of Linux Standard Base and Distribution information, and you need to install redhat-lsb-core pacakge on your current CentOS or RHEL Linux system with the following command:
$ sudo dnf install redhat-lsb-core
or
$ sudo yum install redhat-lsb-core
Outputs:
[devops@mydevops ~]$ sudo dnf install redhat-lsb-core
Last metadata expiration check: 0:00:59 ago on Sat 28 Sep 2019 09:55:29 PM EDT.
Dependencies resolved.
========================================================================================================================
Package Arch Version Repository Size
========================================================================================================================
Installing:
redhat-lsb-core x86_64 4.1-47.el8 AppStream 46 k
Installing dependencies:
redhat-lsb-submod-security x86_64 4.1-47.el8 AppStream 22 k
m4 x86_64 1.4.18-7.el8 BaseOS 223 k
mailx x86_64 12.5-29.el8 BaseOS 257 k
make x86_64 1:4.2.1-9.el8 BaseOS 498 k
ncurses-compat-libs x86_64 6.1-7.20180224.el8 BaseOS 331 k
patch x86_64 2.7.6-8.el8 BaseOS 138 k
postfix x86_64 2:3.3.1-8.el8 BaseOS 1.5 M
spax x86_64 1.5.3-13.el8 BaseOS 217 k
Transaction Summary
========================================================================================================================
Install 9 Packages
Total download size: 3.1 M
Installed size: 8.5 M
Is this ok [y/N]: y
Downloading Packages:
(1/9): redhat-lsb-submod-security-4.1-47.el8.x86_64.rpm 100 kB/s | 22 kB 00:00
(2/9): m4-1.4.18-7.el8.x86_64.rpm 993 kB/s | 223 kB 00:00
(3/9): redhat-lsb-core-4.1-47.el8.x86_64.rpm 179 kB/s | 46 kB 00:00
(4/9): mailx-12.5-29.el8.x86_64.rpm 853 kB/s | 257 kB 00:00
(5/9): ncurses-compat-libs-6.1-7.20180224.el8.x86_64.rpm 1.1 MB/s | 331 kB 00:00
(6/9): make-4.2.1-9.el8.x86_64.rpm 1.4 MB/s | 498 kB 00:00
(7/9): patch-2.7.6-8.el8.x86_64.rpm 819 kB/s | 138 kB 00:00
(8/9): spax-1.5.3-13.el8.x86_64.rpm 925 kB/s | 217 kB 00:00
(9/9): postfix-3.3.1-8.el8.x86_64.rpm 2.8 MB/s | 1.5 MB 00:00
------------------------------------------------------------------------------------------------------------------------
Total 735 kB/s | 3.1 MB 00:04
warning: /var/cache/dnf/AppStream-a520ed22b0a8a736/packages/redhat-lsb-core-4.1-47.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY
CentOS-8 - AppStream 1.6 MB/s | 1.6 kB 00:00
Importing GPG key 0x8483C65D:
Userid : "CentOS (CentOS Official Signing Key) <security@centos.org>"
Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : spax-1.5.3-13.el8.x86_64 1/9
Running scriptlet: spax-1.5.3-13.el8.x86_64 1/9
Running scriptlet: postfix-2:3.3.1-8.el8.x86_64 2/9
Installing : postfix-2:3.3.1-8.el8.x86_64 2/9
Running scriptlet: postfix-2:3.3.1-8.el8.x86_64 2/9
Installing : patch-2.7.6-8.el8.x86_64 3/9
Installing : ncurses-compat-libs-6.1-7.20180224.el8.x86_64 4/9
Installing : make-1:4.2.1-9.el8.x86_64 5/9
Running scriptlet: make-1:4.2.1-9.el8.x86_64 5/9
Installing : mailx-12.5-29.el8.x86_64 6/9
Installing : m4-1.4.18-7.el8.x86_64 7/9
Running scriptlet: m4-1.4.18-7.el8.x86_64 7/9
Installing : redhat-lsb-submod-security-4.1-47.el8.x86_64 8/9
Installing : redhat-lsb-core-4.1-47.el8.x86_64 9/9
Running scriptlet: redhat-lsb-core-4.1-47.el8.x86_64 9/9
Verifying : redhat-lsb-core-4.1-47.el8.x86_64 1/9
Verifying : redhat-lsb-submod-security-4.1-47.el8.x86_64 2/9
Verifying : m4-1.4.18-7.el8.x86_64 3/9
Verifying : mailx-12.5-29.el8.x86_64 4/9
Verifying : make-1:4.2.1-9.el8.x86_64 5/9
Verifying : ncurses-compat-libs-6.1-7.20180224.el8.x86_64 6/9
Verifying : patch-2.7.6-8.el8.x86_64 7/9
Verifying : postfix-2:3.3.1-8.el8.x86_64 8/9
Verifying : spax-1.5.3-13.el8.x86_64 9/9
Installed:
redhat-lsb-core-4.1-47.el8.x86_64 redhat-lsb-submod-security-4.1-47.el8.x86_64
m4-1.4.18-7.el8.x86_64 mailx-12.5-29.el8.x86_64
make-1:4.2.1-9.el8.x86_64 ncurses-compat-libs-6.1-7.20180224.el8.x86_64
patch-2.7.6-8.el8.x86_64 postfix-2:3.3.1-8.el8.x86_64
spax-1.5.3-13.el8.x86_64
Complete!
Once redhat-lsb-core package is installed on your system, and you can type the following command to get the version of your current RHEL or CentOS system:
$ lsb_release -a
Outputs:
[devops@mydevops ~]$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 8.0.1905 (Core)
Release: 8.0.1905
Codename: Core
Conclusion
You should know that how to get the version of CentOS or RHEl Linux system using cat/hostnamectl/lsb_release command or read command on your CentOS or RHEL Linux system.