CentOSLinuxTutorials

How To Check CentOS Version

Check CentOS Version

In this tutorial, we will show you how to check the CentOS version from the command line. As a system administrator, the first question you should ask yourself after getting a new CentOS server to manage is what version of CentOS am I running? The version of the operating system in use on our server is important as it is critical that we have all the latest updates to ensure that the server is secure. There are a few ways to check your VPS hosting is using what version of CentOS. With the commands below you can choose one of them to find out which CentOS version is running on your system.

Prerequisites

  • A server running one of the following operating systems: CentOS Linux.
  • It’s recommended that you use a fresh OS install to prevent any potential issues
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Check CentOS Version

There are several ways on how to check what version of CentOS is running on your system. Below you can find multiple examples on 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 for the check CentOS version system. For additional help or useful information, we recommend you check the official CentOS website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

Save

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button