Screenfetch running in CentOS 8
One of the very first questions a Linux user asks is about confirming the release (OS version) in use. Knowing release helps with highlighting software dependencies and compatibilities, confirms availability of certain features in your OS and simplifies the process of system administration – certain releases have a preferred set of commands for day-to-day management.
With CentOS being a rather popular server grade Linux distro, I can see that many visitors of my blog look for the same guidance quite regularly: check CentOS version. This article introduces 5 of the most common ways to do just that.
Just to be super sure that you’re actually looking at a CentOS distribution of Linux, I suggest you start with the /etc/os-release file. As shown below, it will help you with confirming your Linux distro and its major release version (CentOS and 7 in my case):
Now that we’re sure it’s CentOS, let’s look into the /etc/centos-release file – this will show you the full release version of your operating system:
Interesting: if you’re coming from RedHat infrastructure, you’d normally be looking for /etc/redhat-release file. That’s okay and the good news is this will still work in CentOS:
In fact, if you look at the /etc/redhat-release file on a CentOS server closely, you’ll notice that it is a symbolic link to /etc/centos-release:
Provided that you’re running a recent enough version of Linux, you should have the hostnamectl command installed.
Among other things, hostnamectl provides easy access to the OS release information and Linux kernel version:
Next option you have is to use the RPM package manager to query a special package named centos-release. It will include the exact CentOS release version right in its full package name:
if you’re using RedHat, just do the same for the redhat-release package.
There are many ways to confirm your Linux kernel version, like uname command:
Using the kernel version number – 3.10.0-693 in my example – you can confirm the CentOS release using one of the public version information pages, like the CentOS wikipedia page.
Once you browse to the CentOS wikipedia page, just search for the kernel version number and it should find something like this for you, confirming CentOS version to be 7.4-1708:
Linux Standard Base (LSB) is a joint project by major Linux vendors to standardise configuration and usage of Linux distros. Amonth other things, it provides the lsb_release command that can help you check CentOS version.
Most likely, you’ll have to install it first:
Once installed, run the lsb_release command with the -d option: