20

I can use uname and cat /proc/version but all I get is the kernel version.

How do I know whether I'm running RHEL4 or 5.5 or such?

PP.
  • 3,316
  • 6
  • 27
  • 31

6 Answers6

37

You can find out in the file /etc/issue

cat /etc/issue

And also on redhat based systems, you can find out in /etc/redhat-release

cat /etc/redhat-release 
Richard Holloway
  • 7,456
  • 2
  • 25
  • 30
  • 4
    I should add that `lsb_release -a` can work for modern versions of Red Hat, Debian, and Ubuntu – PP. Jun 04 '13 at 15:23
  • There were no `/etc/issue` or `/etc/redhat-release` files on the redhat server I wanted to interrogate. – Axel Bregnsbo Nov 01 '16 at 11:35
8

cat /etc/redhat-release will tell you.

Scott Pack
  • 14,907
  • 10
  • 53
  • 83
Khushil
  • 553
  • 3
  • 11
5

/etc/redhat-release is the usual way, but be careful if you are working on an unfamiliar server. Administrators have been known to "tweak" redhat-release to permit certain software packages requiring Redhat Enterprise to install on similar distributions which are not officially supported by the vendor. For example, IBM's Lotus Domino package typically looks for RHEL before allowing the installer to run, but it can be installed on CentOS by "faking out" the string in /etc/redhat-release.

Mike
  • 151
  • 1
5

rpm -q --whatprovides /etc/redhat-release can also be used (and it works on both RedHat and CentOS). The version portion of the output should be the OS version.

e.g. An output of "redhat-release-5Server-5.4.0.3" shows that the box is running RHEL 5.4 while "centos-release-5-5.el5.centos" indicates that the box is running CentOS 5.5.

Scott Pack
  • 14,907
  • 10
  • 53
  • 83
gsiems
  • 546
  • 5
  • 8
3

cat /etc/redhat-release

Chopper3
  • 101,299
  • 9
  • 108
  • 239
-1

$ cat /etc/centos-release CentOS Linux release 7.3.1611 (Core) $ cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core)