How to check CentOS version via Command Line Interface

There are several ways on how to check what version of CentOS is running on your system. Below you can find multiple examples on how to determine CentOS version. However, depending on your system not all examples may be applicable. 
First, example uses hostnamectl command: 
# hostnamectl
The next example uses rpm command to do query for centos-release package to reveal CentOS version: 

# rpm --query centos-release
Yet, another alternative is to use lsb_release command. However, this command is part of redhat-lsb package and is not installed by default so the actual lsb_release command may be unavailable on your system. If this is the case it is recommended to use some other alternative approach on how to check CentOS version on your system.
# lsb_release -d
If none of the above does not reveal CentOS version we can try to query release numbers directly. Attempt to read the content of the following files to reveal CentOS version number:
  • /etc/centos-release
  • /etc/os-release
  • /etc/redhat-release
  • /etc/system-release
  • Use cat command to read their content in order to show CentOS version:
    # cat /etc/centos-release
    CentOS Linux release 7.1.1503 (Core) 
    # cat /etc/os-release
    NAME="CentOS Linux"
    VERSION="7 (Core)"
    ID_LIKE="rhel fedora"
    PRETTY_NAME="CentOS Linux 7 (Core)"
    # cat /etc/redhat-release
    CentOS Linux release 7.1.1503 (Core) 
    # cat /etc/system-release
    CentOS Linux release 7.1.1503 (Core)