Knowing your CentOS version is crucial for system administration tasks, software compatibility checks, and troubleshooting. This guide will walk you through the various methods to check the CentOS version on your system.
1. Using the /etc/centos-release File
The /etc/centos-release file contains the CentOS version information. You can easily view this file using the cat command.
cat /etc/centos-releaseThis command will display the CentOS version in a format like CentOS Linux release 7.9.2009 (Core).
2. Using the hostnamectl Command
The hostnamectl command provides various details about the system, including the CentOS version.
hostnamectlLook for the “Operating System” line, which will show something like CentOS Linux 7 (Core).
3. Using the lsb_release Command
The lsb_release command provides Linux Standard Base (LSB) and distribution-specific information.
lsb_release -aThe output will include details like:
Distributor ID: CentOS
Description:    CentOS Linux release 7.9.2009 (Core)
Release:        7.9.2009
Codename:       Core4. Using the /etc/os-release File
The /etc/os-release file contains operating system identification data. View this file with the cat command.
cat /etc/os-releaseYou will see output similar to:
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/"5. Using the rpm Command
The rpm command can be used to query the CentOS release package.
rpm -q centos-releaseThe output will show something like centos-release-7-9.2009.0.el7.centos.x86_64.
Knowing the CentOS version is a fundamental skill for system administrators. By using the methods outlined above, you can quickly determine the CentOS version running on your system. Each method provides the same essential information, so you can choose the one that best fits your workflow.