As a system administrator or a Linux user, it’s crucial to know the version of your CentOS operating system. This information is essential for troubleshooting system issues, ensuring system security and updates, and maintaining compatibility with various software and applications. CentOS, short for Community Enterprise Operating System, is a popular Linux distribution based on Red Hat Enterprise Linux (RHEL). It’s widely used in servers and enterprise environments due to its stability, reliability, and long-term support. In this comprehensive guide, we’ll explore various methods to check your CentOS version, providing step-by-step instructions and helpful tips along the way.
Prerequisites
Before we dive into the different methods to check your CentOS version, ensure that you have the following:
- Access to a CentOS system: You should have physical or remote access to the CentOS machine you want to check the version of.
- Terminal or command line access: Most of the methods we’ll discuss require using the command line interface. Make sure you can open a terminal or SSH into your CentOS system.
- Sudo or root privileges: Some commands may require elevated privileges. If you’re not logged in as the root user, you’ll need sudo access to execute certain commands.
Check CentOS Version
- Checking CentOS Version via GUI
While most of the methods discussed so far involve using the command line, there are also graphical ways to check your CentOS version. Here are a couple of options:
Using System Settings:
- Click on the “Applications” menu in the top-left corner of your CentOS desktop.
- Navigate to “System Tools” and click on “System Settings.”
- In the System Settings window, click on the “Details” icon.
- The CentOS version information will be displayed under the “Overview” tab.
- Checking CentOS Version using Terminal
There are several ways how to check what version of CentOS is running on your system. Below you can find multiple examples of how to determine the CentOS version.
$ cat /etc/redhat-release CentOS release 7 (Final)
You can also use the command “hostnamectl
” to find OS version information in CentOS systems. For example:
$ hostnamectl Static hostname: kvm.idroot.us Pretty hostname: localhost.localdomain Icon name: computer-vm Chassis: vm Machine ID: 3974b10a7fa4421690c2e672917e00b0 Boot ID: 04fb94c0eff94c4ba5a543e085e09ccd Virtualization: kvm Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-325.22.2.el7.x86_64 Architecture: x86-64
Another file that contains the centos version information is /etc/issue
:
$ cat /etc/issue CentOS release 7 (Final) Kernel \r on an \m
The rpm command can also be used to query for the centos version information:
$ rpm -q centos-release centos-release-7.el7.centos.10.x86_64
Another alternative is to use the lsb_release
command:
The lsb_release
the command is not available on CentOS by default. It can be installed by installing the RedHat LSB packages from the base repository:
yum install redhat-lsb -y
$ lsb_release -d Description: CentOS Linux release 7.1.1503 (Core)
Another method, you can use bash script can be used to obtain the CentOS version. The below script serves as an example:
#!/bin/bash full=`cat /etc/centos-release | tr -dc '0-9.'` major=$(cat /etc/centos-release | tr -dc '0-9.'|cut -d \. -f1) minor=$(cat /etc/centos-release | tr -dc '0-9.'|cut -d \. -f2) asynchronous=$(cat /etc/centos-release | tr -dc '0-9.'|cut -d \. -f3) echo CentOS Version: $full echo Major Relase: $major echo Minor Relase: $minor echo Asynchronous Relase: $asynchronous
Save and close the file, then run:
$ ./check-centos-version.sh
Output:
CentOS Version: 8.4.2105 Major Relase: 8 Minor Relase: 6 Asynchronous Relase: 2105
Congratulations! You have successfully checked the CentOS version. Thanks for using this tutorial to the check CentOS version system. For additional help or useful information, we recommend you check the official CentOS website.