Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question
2  
Strictly speaking, if they conflict, none of them is true. –  tripleee Jan 27 '13 at 7:57

2 Answers 2

up vote 9 down vote accepted

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
centos-release-5-5.el5.centos

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
23.2.2
24.20060715
1.el5
35.el5
32.2.1.1
4
2.fc6
45.el5.centos
4.el5
1
2.el5
0.1
5.el5
1.el5
15.el5

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 ' '
initscripts-9.03.27-1.el6.centos.x86_64

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 ' '
initscripts-8.45.30-3.el5_5.1
share|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 2.6.35.14-106.fc14.x86_64 (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

-or-

uname -a
Linux grinchy 2.6.35.14-106.fc14.x86_64 #1 SMP Wed Nov 23 13:07:52 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
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.