I was checking for the Redhat release so this time I used three different commands. Two commands gave the same result but the third command gave different result. Which one is right.

[root@DBtest2 ~]# cat /etc/redhat-release
    Red Hat Enterprise Linux Server release 4 (Tikanga)
    [root@DBtest2 ~]# /usr/bin/lsb_release --d
    Description:    Red Hat Enterprise Linux Server release 4 (Tikanga)
    [root@DBtest2 ~]# cat /etc/issue
    Red Hat Enterprise Linux Server release 5.5 (Tikanga)
    Kernel \r on an \m
  • 2
    Strictly speaking, if they conflict, none of them is true. – tripleee Jan 27 '13 at 7:57

I'd lean more toward the redhat-release. You could use the rpm -q --whatprovides command to determine the name of the package that is providing /etc/redhat-release.

[tim@c5 ~]$ rpm -q --whatprovides /etc/redhat-release

If you don't trust that, then you could look at the detailed information of the package. Pay attention to Version and Release.

[tim@c5 ~]$ rpm -qi --whatprovides /etc/redhat-release
Name        : centos-release               Relocations: (not relocatable)
Version     : 5                                 Vendor: CentOS
Release     : 5.el5.centos                  Build Date: Sun 25 Apr 2010 04:25:31 PM PDT
Install Date: Thu 20 May 2010 04:07:47 PM PDT      Build Host: builder10.centos.org
Group       : System Environment/Base       Source RPM: centos-release-5-5.el5.centos.src.rpm
Size        : 35485                            License: GPL
Signature   : DSA/SHA1, Mon 26 Apr 2010 04:40:57 PM PDT, Key ID a8a447dce8562897
Summary     : CentOS release file
Description :
CentOS release files

If you still don't trust what you're seeing, you could try looking at

[tim@c5 etc]# rpm -qai | grep Release | awk -F' ' '{print $3}' | head -15

Hopefully you'll find some sort of pattern that answers your question while searching through all the package information.

Good luck.

Update #1:

You could also try:

[tim@c6 ~]# rpm -q --whatrequires \
  $(rpm -ql \
    $(rpm -q --whatprovides /etc/redhat-release)
  ) | grep -v ' '

Update #2:

I wanted to make sure the command I provided in my first update worked right so I spun up a RHEL5 instance at AWS. It looks like it works.

[root@ip-10-172-23-67 ~]# rpm -q --whatrequires \
>   $(rpm -ql \
>     $(rpm -q --whatprovides /etc/redhat-release)
>   ) | grep -v ' '
| improve this answer | |
  • Right you are. But I don't remember any package depending on the release, so some creative sysadmin could well have left out updating that "because it isn't security critical" (or whatever). It is much more robust to look for the exact features you require. – vonbrand Jan 28 '13 at 1:36
  • Totally. In the past (like RH5 or 6 (not RHEL)) I'd update the redhat-release file to force a ghetto update - not sure if this still works. :) – livingstaccato Jan 28 '13 at 3:06

Maybe you can do one of the following:

% cat /proc/version 
Linux version (mockbuild@x86-09.phx2.fedoraproject.org) (gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC) ) #1 SMP Wed Nov 23 13:07:52 UTC 2011


uname -a
Linux grinchy #1 SMP Wed Nov 23 13:07:52 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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