How to Check CentOS or Rocky Linux Version

November 8, 2024

Introduction

Knowing the operating system version on your machine can be helpful when troubleshooting system issues. It also helps ensure the system is up-to-date, preventing potential security risks and vulnerabilities.

This tutorial will show you how to perform version checks on CentOS and Rocky Linux.

How to Check Version in CentOS and Rocky Linux.

Prerequisites

How to Check CentOS or Rocky Linux Version from Command Line

Users can obtain version information on CentOS and Rocky Linux straight from the terminal. The following sections explain how to use hostnamectl, rpm, and lsb_release commands to see which version of the operating system runs on the computer.

Find CentOS or Rocky Linux Version with hostnamectl Command

The hostnamectl command queries the system hostname and performs hostname configuration. In addition to the version number, it shows which Linux kernel the system uses.

See the version information by executing the hostnamectl command without any arguments:

hostnamectl
An example of Rocky Linux version number in the output of the hostnamectl command.

Find CentOS or Rocky Linux Version with RPM

RPM is a free, open-source package manager created for Red Hat Linux and related Linux distributions. Use the following rpm commands to find out the full package name and the release version of CentOS or Rocky Linux:

  • On CentOS, enter the following:
rpm –qa centos-release 
Example of RPM command to view version of CentOS.
  • On Rocky Linux, type:
rpm -qa rocky-release
Example of RPM command to view version of Rocky Linux.

lsb Command to Display Details of CentOS Linux Release

LSB (Linux Standard Base) is a joint project of several Linux distributions to standardize software system structure. One of the commands available from the command line is lsb_release. Its output will indicate which OS version runs on the computer.

Proceed with the steps below to install and use lsb_release:

1. Install the command with YUM:

sudo yum install redhat-lsb-core 

Type y and press Enter to confirm the installation.

Note: The redhat-lsb-core package is unavailable on Rocky Linux, so the lsb_release command can only be used to check the CentOS version.

2. View CentOS version information with the following command:

lsb_release -d 

The output displays basic system information, including the OS version.

The lsb_release command showing the CentOS version on the system.

Check CentOS and Rocky Linux Version in Release File

To check which Linux distro and major release version is installed on the machine, print the contents of the release file using the cat command:

cat /etc/os-release

The output reveals the name of the operating system, the version number, and other specifics.

An example of Rocky Linux command output for the operating system and release version.

Alternatively, use the cat command to read the /etc/centos-release file for CentOS and /etc/rocky-release for Rocky Linux.

Check Linux Kernel Version on CentOS and Rocky Linux

Knowing the kernel version helps ensure hardware and software compatibility. Find out which Linux kernel version runs on the system with the uname command:

uname –r

The output shows the version number of the operating system kernel. In the example displayed below, the system uses kernel 5.14.0-427.

An example of the Linux kernel version displayed in Rocky Linux.

Conclusion

After reading this tutorial, you will be able to check the CentOS or Rocky Linux version installed on your computer. The article also showed how to check the Linux kernel version.

To check the version of other Linux operating systems based on Red Hat, read how to check Linux Red Hat (RHEL) version.

Was this article helpful?
YesNo
Marko Aleksic
Marko Aleksić is a Technical Writer at phoenixNAP. His innate curiosity regarding all things IT, combined with over a decade long background in writing, teaching and working in IT-related fields, led him to technical writing, where he has an opportunity to employ his skills and make technology less daunting to everyone.
Next you should read
How to Install CentOS 8 {with Screenshots}
December 14, 2019

Since there is no way to upgrade from CentOS 7 to CentOS 8, users need to go through the entire installation...
Read more
How to Upgrade Linux Kernel in CentOS 7
October 8, 2019

The Linux kernel is the underlying software architecture of each Linux distribution. It provides and defines...
Read more
How to Check Your Ubuntu Version
August 15, 2024

Finding out which Ubuntu version is running on your system can be important when troubleshooting issues or...
Read more
How to Set or Change a Hostname in CentOS 7
October 21, 2018

This technical guide is for users who already have a server running the CentOS 7 operating system on a...
Read more