CentOS (Community Enterprise Operating System) is a free, open-source Linux operating system that is based on Red Hat Enterprise Linux (RHEL). It is designed to be a stable, secure, and scalable platform for enterprise-level computing environments.
This article aims to explain all possible methods to check the CentOS version. The supported content of this guide is mentioned below:
- Using a centos-release File
- Using the lsb_release Command
- Using hostnamectl Command
- Using the uname Command
- Using the rpm Command
Let’s start with the centos-release file.
Using a centos-release File to Check the CentOS Version
The “cat” command displays the contents inside the file. To get the version of CentOS, use the “cat” command and specify the name of the /etc/centos-release file as follows:
$ cat /etc/centos-release
The output displays the version “7.9.2009 (Core)” of CentOS that is installed on our system.
Using the lsb_release Command to Check the CentOS Version
The user can utilize the “lsb_release” command with the “-a” option to display the current release the CentOS:
$ lsb_release -a
This command will display information about the Linux distribution, including the CentOS “7.9.2009” version.
Using hostnamectl Command to Check the CentOS version
To check the installed version of CentOS, the “hostnamectl” command is utilized as below:
$ hostnamectl
The output displays the detailed information of the current operating system, including version.
Using the uname Command to Check the CentOS Version
The users can utilize the “uname” command with the “r” option to display the released version of CentOS. For this, execute the below script:
$ uname -r
This command will display the kernel version, which can be used to determine the version of CentOS that is installed.
Using the rpm Command to Check the CentOS Version
To check the centos-release package, use the rpm command to query the installed version of the centos package:
$ rpm -q centos-release
This command will display the version of the centos-release package, which can be used to determine the version of CentOS that is installed.
Conclusion
CentOS offers the “lsb_release”, “hostnamectl”, and “uname” commands to check the CentOS version. Additionally, the “centos-release” file contains information on the installed version of CentOS. This guide has explained all possible ways to check the CentOS version.