Sometimes we need information about the OS version that we use. Many benefits can be obtained if we know the OS version exactly. Some of our reasons for getting information about the OS version, namely :
- Compatibility of applications that will be installed on our system
- When we are troubleshooting an applications, we have to know the precious version of the OS where the application is running
- Knowing the software out of date, will keep us from risking security problems
There are several ways to check which OS version we are currently using. This article will be discussing several ways to check the CentOS version, several of it are : RPM command line,
lsb_release -d command line,
hostnamectl command line. The details of these option will be described below.
RPM command line
With rpm command, we can find out the full package name and the release version of our CentOS. RPM is a free and open-source package manager for Red Hat Linux and its related distributions. CentOS version valid for CentOS 6 and higher.
[ramans@otodiginet ~]$ rpm -q centos-release centos-release-8.2-2.2004.0.1.el8.x86_64
CentOS Release File
We can query the information of CentOS version from the release file. The CentOS release file is located on
/etc/os-release. We can display the information using cat or more command line.
[ramans@otodiginet ~]$ 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/"
lsb Command Line
Using command line which was produced by LSB (Linux Standard Base). LSB (Linux Standard Base) is a joint project of several Linux distributions to standardize software system structure. The Linux Standard Base (LSB) is a joint project by several Linux distributions under the organizational structure of the Linux Foundation to standardize the software system structure, including the Filesystem Hierarchy Standard used in the Linux kernel. We have to install the lsb package first before using its command line.
[ramans@otodiginet ~]$ sudo yum install redhat-lsb-core
After installation was completed, we are able to query CentOS version by submitting command line below :
[ramans@otodiginet ~]$ lsb_release -d Description: CentOS Linux release 8.2.2004 (Core)
hostnamectl Command Line
Querying CentOS version also could be done with hostnamctl command line. This command displays information from the /etc/centos-release file, uname –a file. This command is available starting from CentOS version 7 and above.
[ramans@otodiginet ~]$ hostnamectl Static hostname: otodiginet Icon name: computer-vm Chassis: vm Machine ID: ee522ac0c8884768b46b776d9ef518ea Boot ID: 29e91c5dbeac4eeb8fc0a0465111bf13 Virtualization: vmware Operating System: CentOS Linux 8 (Core) CPE OS Name: cpe:/o:centos:centos:8 Kernel: Linux 4.18.0-193.6.3.el8_2.x86_64 Architecture: x86-64
There are several option to check the version of our CentOS operation system. On this article, we have shown you how to use command line to query the CentOS version : hostnamectl, rpm -q centos-release, lsb_release -d and cat /etc/os-release.