Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

7 Answers

up vote 27 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.

share|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
5  
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

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.

share|improve this answer

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).

share|improve this answer

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).

share|improve this answer

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

share|improve this answer
cat /etc/redhat-release
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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