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:
This command outputs the CentOS version, release number, and other details in a single line, such as
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.
In the output, look for the Operating System and Kernel sections:
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.
This will return the exact CentOS release package, providing details like:
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.
This command displays several lines of information, including the version:
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:
If lsb_release isn’t installed, you can add it with:
After installation, running lsb_release -a will output information similar to:
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.
This command outputs the kernel version, which looks something like:
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.