How to find out what version of RHEL I'm using?

if grep -q -i "release 6" /etc/redhat-release
then
  echo "running RHEL 6.x"
fi

This would be the simplest way I can think of.


You can also use the lsb_release command. If you're already certain it's RHEL, getting the major version number is:

majversion=$(lsb_release -rs | cut -f1 -d.)

Use rpm -q redhat-release-server

The /etc/redhat-release file could have been edited by an admin looking to install third party software without performing an actual OS upgrade.

Tags:

Bash

Rhel