7 Useful Commands to Check Your CentOS Version

7 Useful Commands to Check Your CentOS Version

CentOS is a popular open-source Linux operating system used for servers and web hosting. It is based on Red Hat Enterprise Linux and is known for its stability and security. In this article, we will discuss how to check the version of CentOS you are running on your system.


Check CentOS Version Using the “cat” Command

This is the easiest and quickest method to check your CentOS version. Simply open the terminal and type the following command:

cat /etc/centos-release

You should see an output similar to this:

CentOS Linux release 7.9.2009 (Core)

Check CentOS Version Using the “rpm” Command

This method involves using the rpm command, which is used to manage RPM (Red Hat Package Manager) packages on your system. To check your CentOS version, use the following command:

rpm -q centos-release

The output of this command shows the version of the centos-release package installed on your system. The package version corresponds to the version of CentOS you are running. For example, the output of the above command may look like:

centos-release-7-9.2009.0.el7.centos.x86_64

In this case, you can see that the version of CentOS you are running is 7.9.2009.


Check CentOS Version Using the “/etc/os-release” File

The /etc/os-release file contains information about the operating system, including the version of CentOS you are running. To check your CentOS version, use the following command:

cat /etc/os-release

The output of this command displays the contents of the /etc/os-release file. Look for the “VERSION_ID” field, which contains the version of CentOS you are running. For example, the output may look like:

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"

Check CentOS Version Using the “hostnamectl” Command

The hostnamectl command is used to manage the hostname and related settings on your system. To check your CentOS version, use the following command:

hostnamectl

The output of this command displays various information about your system, including the operating system and version. For example, the output may look like:

Static hostname: localhost.localdomain
    Icon name: computer-vm
    Chassis: vm
    Machine ID: <ID>
    Boot ID: <ID>
    Virtualization: vmware
    Operating System: CentOS Linux 7 (Core)
    CPE OS Name: cpe:/o:centos:centos:7
    Kernel: Linux 3.10.0-1127.el7.x86_64
    Architecture: x86-64

Using the “lsb_release” Command

The lsb_release command displays information about the Linux Standard Base (LSB) on your system, including the version of CentOS you are running. To use this method, run the following command:

lsb_release -a

The output of this command will show the LSB information, including the version of CentOS you are running. For example:

LSB Version:	:base-4.1-amd64:base-4.1-noarch:core-4.1-amd64:core-4.1-noarch:graphics-4.1-amd64:graphics-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:	CentOS
Description:	CentOS Linux release 7.9.2009 (Core)
Release:	7.9.2009
Codename:	Core

Using the “uname” Command

The uname command displays information about the system, including the version of the operating system. To use this method, run the following command:

uname -r

The output of this command shows the version of the operating system’s kernel. The version of the kernel corresponds to the version of CentOS you are running. For example:

3.10.0-1127.el7.x86_64

Using the “cat /proc/version” Command

The /proc/version file contains information about the version of the operating system’s kernel. To use this method, run the following command:

cat /proc/version

The output of this command shows the version of the operating system’s kernel and other details about the system. For example:

Linux version 3.10.0-1127.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) #1 SMP Tue Mar 31 23:36:51 UTC 2020

Conclusion:

In this article, we discussed four different methods to check the version of CentOS you are running on your system. Whether you are a system administrator or a developer, knowing the version of your operating system is important for troubleshooting, compatibility, and security purposes. I hope this guide was helpful in showing you how to check the version of CentOS you are running.

Got questions or suggestions on the article? Don’t hesitate to leave a comment below. Your feedback is valuable to us and helps improve the content quality. And don’t forget to share this article with others who might find it useful. Looking forward to hearing from you!

If our tutorials helped you, please consider buying us a coffee. We appreciate your support!

Thank you for your support.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top