4 Ways to Check CentOS or RHEL Version


If you're using CentOS or RHEL (Red Hat Enterprise Linux), you might be wondering how to check what version you're running. Luckily, there are several easy ways to find out.

In this article, we'll go over four methods you can use to check version of CentOS or RHEL that you're running. We'll also provide examples and step-by-step instructions for each method.

Check /etc/redhat-release File

The first method we'll cover is to check contents of /etc/redhat-release file. This file contains information about version of CentOS or RHEL that you're running, including release number and update level.

To check contents of /etc/redhat-release file, follow these steps −

Open a terminal window on your CentOS or RHEL system.

Type following command and press Enter −

cat /etc/redhat-release

The output should display version of CentOS or RHEL that you're running. For example, if you're running CentOS 7, output might look like this −

CentOS Linux release 7.9.2009 (Core)

If you're running RHEL, output might look similar, but with "Red Hat Enterprise Linux" instead of "CentOS Linux".

Use hostnamectl Command

The hostnamectl command is a useful tool for checking system information on CentOS or RHEL. In addition to displaying version of operating system, hostnamectl can also display other system information such as hostname, kernel version, and architecture.

To use hostnamectl command to check version of CentOS or RHEL that you're running, follow these steps −

Open a terminal window on your CentOS or RHEL system.

Type following command and press Enter −

hostnamectl

The output should display various system information, including version of CentOS or RHEL that you're running. For example, if you're running CentOS 7, output might look like this −

Static hostname: myserver.example.com
Icon name: computer-server
Chassis: server
Machine ID: 123456789abcdef
Boot ID: 0123456789abcdef
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1160.45.1.el7.x86_64

If you're running RHEL, output might look similar, but with "Red Hat Enterprise Linux" instead of "CentOS Linux".

Use lsb_release Command

The lsb_release command is a utility for displaying Linux Standard Base (LSB) information about operating system. This command can display information such as distributor ID, release number, and description of operating system.

To use lsb_release command to check version of CentOS or RHEL that you're running, follow these steps −

Open a terminal window on your CentOS or RHEL system.

Type following command and press Enter −

lsb_release -a

The output should display LSB information about operating system, including distributor ID, release number, and description. For example, if you're running CentOS 7, output might look like this −

LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.9.2009 (Core)
Release:        7.9.2009
Codename:       Core

If you're running RHEL, output might look similar, but with "Red Hat Enterprise Linux" instead of "CentOS".

Use rpm Command

The rpm command is a powerful tool for managing packages on CentOS or RHEL. In addition to installing and removing packages, rpm can also be used to query information about installed packages, including version of operating system.

To use rpm command to check version of CentOS or RHEL that you're running, follow these steps −

Open a terminal window on your CentOS or RHEL system.

Type following command and press Enter −

rpm -q centos-release

If you're running RHEL, replace "centos-release" with "redhat-release".

The output should display version of operating system that you're running. For example, if you're running CentOS 7, output might look like this −

centos-release-7-9.2009.1.el7.centos.x86_64

If you're running RHEL, output might look similar, but with "redhat-release" instead of "centos-release".

Additional Tips

While methods we've discussed are most common ways to check your CentOS or RHEL version, there are a few other tips you might find helpful −

Use "uname" command - "uname" command can display information about kernel version, including version of CentOS or RHEL you're running. To use "uname" command, open up a terminal and type following command −

uname -r

This will output kernel version, which can give you an idea of which version of CentOS or RHEL you're running.

Check "release" file - In addition to "/etc/redhat-release" file we mentioned earlier, there's also a "release" file located in "/etc" directory that can provide information about your operating system version. To view contents of "release" file, open up a terminal and type following command −

cat /etc/release

This will display information about your operating system version.

Use graphical tools - If you prefer a graphical interface, there are a few different tools you can use to check your CentOS or RHEL version. For example, you can open up "System Settings" application and navigate to "Details" section to see information about your operating system version. You can also use tools like "Hardinfo" or "lshw-gui" to view system information, including operating system version.

Consult documentation - If you're not sure which version of CentOS or RHEL you're running, you can always consult documentation for your specific distribution. CentOS and RHEL websites both have documentation that can help you identify your operating system version and learn more about how to use it.

Conclusion

In this article, we've covered four easy ways to check version of CentOS or RHEL that you're running. These methods include checking contents of /etc/redhat-release file, using hostnamectl command, using lsb_release command, and using rpm command.

No matter which method you choose, it's important to know version of operating system you're running, as this information can be helpful when troubleshooting issues or installing software. So, next time you're wondering which version of CentOS or RHEL you're running, just use one of these four methods and you'll have answer in no time!

Updated on: 31-Mar-2023

14K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements