Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills
31.10.2024

How to Check the CentOS Version

Knowing the CentOS version is essential when installing compatible software, troubleshooting, or managing updates on a CentOS server. CentOS provides several commands to display the version information, and here’s a guide to checking your CentOS version accurately.

1. Using the cat Command to Display the Release File

CentOS stores version information in the /etc/centos-release file. The cat command can display this information:

cat /etc/centos-release

This command outputs the CentOS version, release number, and other details in a single line, such as

CentOS Linux release 8.5.2111 (Core)

2. Checking Version with hostnamectl

The hostnamectl command provides information about the operating system, kernel, and version. This method is especially useful in newer CentOS versions.

hostnamectl

In the output, look for the Operating System and Kernel sections:

Operating System: CentOS Linux 8 Kernel: Linux 4.18.0-305.el8.x86_64

3. Using the rpm Command

The rpm command can also be used to display CentOS version information, as the release information is stored in an RPM package.

rpm -q centos-release

This will return the exact CentOS release package, providing details like:

centos-release-8.5-4.2111.el8.x86_64

4. Checking the Version in /etc/os-release

The /etc/os-release file contains detailed information about the Linux distribution, and it’s commonly available on most Linux systems.

cat /etc/os-release

This command displays several lines of information, including the version:

NAME=”CentOS Linux” VERSION=”8 (Core)” ID=”centos” ID_LIKE=”rhel fedora” VERSION_ID=”8″ PLATFORM_ID=”platform:el8″

5. Using lsb_release (if Installed)

The lsb_release command, part of the Linux Standard Base, displays information about the distribution. If it’s installed on your CentOS system, you can use it to check the version:

lsb_release -a

If lsb_release isn’t installed, you can add it with:

sudo yum install -y redhat-lsb-core

After installation, running lsb_release -a will output information similar to:

Distributor ID: CentOS Description: CentOS Linux release 8.5.2111 (Core) Release: 8.5.2111 Codename: Core

6. Verifying the Kernel Version with uname

The uname command provides kernel information, which can indirectly indicate CentOS’s version, especially if a specific kernel version is tied to a CentOS release.

uname -r

This command outputs the kernel version, which looks something like:

4.18.0-305.el8.x86_64

While this doesn’t show the CentOS version directly, knowing the kernel version can be useful when troubleshooting or installing software.

Summary of Commands

Here’s a quick summary of the commands to check the CentOS version:

  • cat /etc/centos-release: Displays version information.
  • hostnamectl: Shows system and version details.
  • rpm -q centos-release: Checks the CentOS release package.
  • cat /etc/os-release: Shows distribution and version details.
  • lsb_release -a: (Requires installation) Shows distribution information.
  • uname -r: Shows kernel version.

Conclusion

Checking the CentOS version is straightforward with multiple command options available. By knowing the version, you can better manage updates, install compatible packages, and ensure system stability.

Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills