How to check if the running distribution is OL or RedHat
By jorge_neidisch on May 15, 2012
Note: this is not intended to be an official way to detect or identify a running linux distribution.
The PDFs linked here are useful to identify the running Linux version.
RedHat (RHEL) provides the file /etc/redhat-release, installed by the package redhat-release. Oracle Linux (OL) adds its own file /etc/enterprise-release, installed by enterprise-release, OL 6 adds /etc/oracle-release, installed by oraclelinux-release. As of OL 6, /etc/redhat-release retains the RHEL content.
my-rhel-server# rpm -qf /etc/redhat-release
my-oel-server# rpm -qf /etc/redhat-release
The PDFs from the link above gives a more detailed and precise information.
Some other methods are easily found just google-ing a bit, and may be prone to cause confusion. For instance, it's also possible to check /proc/version, although this one won't make it clear:
# cat /proc/version
Linux version 2.6.18-2184.108.40.206.1.el5 (...) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-51))
A bit more reliable seems to be /etc/issue or /etc/issue.net:
# cat /etc/issue.net | head -1
Oracle Linux Server release 5.7