How can I determine from the shell with no privileges what the Red Hat Enterprise Linux version is, for example is it RHEL 4 or RHEL 5.1?

link|improve this question

65% accept rate
feedback

7 Answers

up vote 11 down vote accepted

You can use the lsb_release command on recent linux distributions. If you issue:

lsb_release -i -r

it will tell you the Distribution and Version. This is a little bit more accurate than accessing files that may or may not have been modified by the admin or a software package. As well as working across multiple distros.

link|improve this answer
1  
command not found on my CentOS 5.4 box :( – gbjbaanb Dec 1 '09 at 17:04
@gbjbaanb: That's strange I tested it on a fresh 5.4 minimal install and it worked just fine... – Zypher Dec 1 '09 at 18:25
2  
lsb_release -i -r -bash: lsb_release: command not found. However, cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.6 (Tikanga) – Tom May 10 '11 at 12:12
feedback

You can look at the contents of /etc/redhat-release, which will look something like this:

$ cat /etc/redhat-release 
CentOS release 5.4 (Final)

The contents are different for an actual RHEL system. This technique works on all RedHat derivatives, including CentOS, Fedora, and others.

link|improve this answer
feedback

I prefer to use the /etc/issue file.

$ cat /etc/issue

I've seen many situations where /etc/redhat-release has been modified to meet software compatibility requirements (Dell or HP's management agents, for instance).

link|improve this answer
feedback

Assuming it truly is a Red Hat release (not Centos):

rpm -q redhat-release

Or just run:

uname -r

And map the output. 2.6.9 kernels are RHEL4, 2.6.18 kernels are RHEL5. If necessary, you can map the full version to the specific update releases from Red Hat (i.e. 2.6.9-89 is RHEL5 U4).

link|improve this answer
feedback

If you have RHEL, this will work (verified on RHEL 5.5):

/usr/bin/lsb_release --d

This will also work on CentOS.

Edit: This tool is included in the package "redhat-lsb", you need to have this installed: yum info redhat-lsb | grep Repo

Repo : installed

link|improve this answer
feedback
cat /etc/redhat-release
link|improve this answer
feedback

A really stupid way is to look at the GRUB menu which usually includes such information :

/boot/grub/menu.lst

This not the smartest way to do such a thing but will work on any distribution / UNIX that uses GRUB.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.