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.
Prerequisites
- System running CentOS or Rocky Linux.
- Command-line access.
- A user with sudo privileges.
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
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
- On Rocky Linux, type:
rpm -qa rocky-release
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.
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.
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.
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.