How To Determine CentOS or Red Hat Version

Call Sales: 877-435-2445

Linux Services

Blog

How To Determine CentOS or Red Hat Version

Posted by Jeff H. 03/10/2009

Versions. Versions. Versions. Understanding versions for Linux systems is not as easy as one may expect. When you manage Linux servers daily, you get used to the nomenclature, but unless you live and breath Linux, the versions can be tedious to deal with.

The numerous Linux distributions combined with differing practices by control panel vendors produces dizzying array of versions, releases, hot fixes, errata, bug fixes, patches, updates, and workarounds. Further complicating matters, many vendors do not update version numbers when they patch something – they simply tack on a letter or another decimal place. Red Hat, for example, often “back ports” security fixes into prior releases. While this practice is required to keep older versions secure, back ports make it difficult to decipher what has and has not been fixed with any particular software package. Control panel vendors use varying naming and numbering schemes for their updates, making it difficult for the busy business owner to know if their servers are updated or not. To help untangle this mess, I want to provide you with a few tips on how to find the version (distributions) of your Linux OS.

Distributions vs. Versions
Linux has many flavors. Fedora and Red Hat “distributions” are popular in the US while SUSE is a favorite in Europe. Other distributions like Mandrake, Trustix and YellowDog target specific user and market segments. CentOS is a rapidly growing new comer to the field. CentOS is a version of Linux derived from Red Hat Enterprise Linux (RHEL). Many control panel vendors now support CentOS in addition to RHEL and Fedora.

RHEL, Fedora and CentOS are among the most frequently encountered when dealing with dedicated hosting providers, so we will focus on those throughout this tutorial.

Most Red Hat-based distributions should have a file called redhat-release. You can find it in:

/etc/redhat-release

You just need to view this file using:

cat /etc/redhat-release

This should return the version you are using. Note that this file can be manually changed or updated but provided that someone has not modified this file, the information should be accurate. On a RHEL 3 system you will see something like:

Red Hat Enterprise Linux ES release 3 (Taroon Update 6)

For now you can ignore the bit in the parenthesis. This tells you that your distribution is Red Hat Enterprise Linux ES Release 3, more frequently referred to as RHEL 3. The ES stands for Enterprise Server, which is what you will likely encounter if you lease a system from a dedicated server provider. Red Hat provides three versions of the enterprise edition called workstation (WS), enterprise server (ES) and advanced server (AS) releases. You can read more about the differences between these over at Red Hat.

If you happen to be using Fedora you will see something similar to:

Fedora Core release 1 (Yarrow)

This indicates you are using the Fedora distribution. Core 1 is the version and Yarrow is a release nickname. You will typically encounter this referred to as FC1.

Another example, is CentOS:

CentOS release 4.2 (Final)

This says you are using CentOS, the free version derived from RHEL.

Using the /etc/redhat-release file, you can determine your distribution type and often your version.

Linux Versions
Linux distributions often have “versions”. Versions are things like Red Hat 7.3, RHEL 3, or RHEL 4. These represent major releases. When someone asks what version of Red Hat you are using, you would likely reply with RHEL 3 or RHEL 4. Fedora has “Core” releases. Core releases are major version differences. An upgrade from Fedora Core 1 to Fedora Core 2 is non trivial. Major components of Linux, including the kernel itself, undergo major upgrades. So, to keep terms straight, if you see:

Fedora Core release 1 (Yarrow)

As the output from /etc/redhat-release, you are running the Fedora Core distribution and the version is Core 1.

Linux Updates
RHEL and CentOS have updates between major releases. Fedora’s development cycle is so fast that several new versions are released per year. This rapid update pace is why we recommend CentOS or RHEL for production servers, where maintenance, reliability and continuity are more important than bleeding edge features.

If you look at the redhat-release file, you will see something like “Update 6”. This means you are running Update 6 for RHEL 3. Updates are major package releases from Red Hat. You should always use the latest update for your RHEL version.

There is a bit of good news with CentOS. They use a simple decimal increment system. So CentOS 4.1 is an update to 4.0. CentOS 3.6 is and update from 3.5, which is an update from 3.4 and so on. A simple approach, I wish other vendors would use.

For security reasons, you should be running the latest update or version of your Linux distribution. You can check the Red Hat or CentOS web sites for the latest version information. Fortunately, we keep track of versions for you in our version watch section of our blog.

Errata
Lastly, I want to touch on errata. Errata are simply bug fixes and security updates released by Red Hat, Fedora and CentOS. Errata are frequent for Linux and unlike Microsoft’s Patch Tuesday, there is no set schedule for errata. It is not uncommon to see several errata appear in one day. The urgency of the bug fix depends on the impact it may have on your server’s operation or security. Some security issues demand immediate attention and errata should be applied as soon as possible. Other issues may be minor and can wait until your next scheduled maintenance period.

Keeping your system fully patched with errata is essential for security. Unfortunately, some errata may interfere with control panels like cPanel, Ensim, or Plesk. So you may need to check with your control panel vendor before rushing to apply the latest bug fix. Lastly, not all errata apply to your server. For example, when we secure systems we remove 100’s of unnecessary software items; this reduces your exposure to potential security problems. In fact, many of the errata that are released daily deal with desktop, GUI, and similar type software often not found on properly secured servers.

Software Versions

A major source of confusion with RHEL, CentOS and Fedora are software version numbers. Red Hat often back-ports security and bug fixes into older versions of the software. For example, RHEL 3 Update 6 uses PHP version 4.3.2. But if you visit the PHP web site, you will see PHP 4.4.1 and PHP 5.1.1. So is your PHP version up to date? Well it depends on what you mean. Red Hat will back port important security and bug fixes from 4.4.1 to 4.3.2. This approach assures that your PHP version changes as little as possible while incorporating important security fixes. Red Hat uses release numbers to differentiate minor version changes they make to PHP 4.3.2. Right now they are on PHP 4.3.2 Release 26.ent. This version has all major security patches that 4.4.1 has but at the core it is still 4.3.2. So if you have all of the errata for your RHEL version installed, you will be using the latest Red Hat version of PHP but not the latest PHP release. To use the latest PHP release, you would have to manually compile PHP or find a third party that has built RPMs for your distribution.

Similar version issues arise with MySQL, Apache, Sendmail, and other major programs. If you are using a control panel, the ability to use a third party solution or manually use the latest Apache or PHP release may be limited. It is best to check with a system administrator familiar with your control panel before updating to a version not released by Red Hat.

Summary
Using your redhat-release file, you can determine your distribution, version and update number. This information is very helpful for technical support staff as well as knowing if you are up to date with the latest patches. Having this info can help you quickly determine if software will be compatible with your system. Keeping on top of errata can keep your system secured and running smoothly.

Comments

rclang commented on How To Determine CentOS or Red Hat Version

rclang · 01/25/2010 04:39 pm

a small point but it’s /etc/redhat-release for the version information. verified on fc-8,fc-9,fc-11 and CentOS 5.4. thanks for the information.

Juli Z commented on How To Determine CentOS or Red Hat Version

Juli Z · 09/07/2010 02:44 pm

You are absolutely correct.  The file is /etc/redhat-release not /etc/Red Hat/release.

I’ve updated our post.  It looks like spell check went crazy there.

[CC] commented on How To Determine CentOS or Red Hat Version

[CC] · 03/09/2011 05:46 am

Hi, this trick didn’t work for me; tested on CentOS 5.5; the “real” trick is to use wildcards:
cat /etc/*release*

DEnnis commented on How To Determine CentOS or Red Hat Version

DEnnis · 04/03/2011 11:33 am

Please can anybody help me with the command in CENTOS 5.4?

Thank you

Jeff H. commented on How To Determine CentOS or Red Hat Version

Jeff H. · 04/04/2011 08:10 am

@DEnnis
Try cat /etc/centos-release

I don’t remember which distribution it was, but Red Hat required CentOS remove all Red Hat logs and branding, so they changed the name of the release file.

Don’t forget to use uname -a to check for i386 vs. x86_64.

I should probably update this to a new tutorial just for CentOS, since others have asked for it.

Romones commented on How To Determine CentOS or Red Hat Version

Romones · 04/10/2011 01:04 am

Hello,
thanks for a useful post.
I’m looking for a bit deeper clues to undertand the release version.
I mean, could you please help me with a link on a resourse or a name a book with description of what really determines the release version?
Is this the kernel or glibc or yum or rpm version that defines CentOS as 5.5 and not as 5.4?
As i understand distributions are distinguished by their developers vision on vanilla linux kernel with all consequent changes to c libs and filesystem organisation, and their approach to managing software in the system. But what packages determine version upgrade?
Or is it like: if i have for example kernel version 2.6.18-194.32.1.el5
and glibc version glibc-2.5-49 and yum version yum-3.2.22-26 and X package of Y version -than this the CentOS 5.5
I would really appreciate a point to the direction for where to dig further.
Thank you.

Ronald Watson commented on How To Determine CentOS or Red Hat Version

Ronald Watson · 04/11/2011 04:24 pm

Although I think this is a great post, you still can’t use /etc/redhat-release to get a true representation of the release level.

To explain, I had CentOS 5.5 system for the last few months as a sandbox machine, using yum update to keep the packages current.  When CentOS 5.6 was released a few days ago, I immediately downloaded the DVD and installed it on another VM.  I was trying to correct a problem with mouse cursor control on a VM in a 2nd monitor display with an ATI driver.  The 5.6 installed VM worked just fine.  The 5.5 installed VM did not, yet when I checked /etc/redhat-release, the file reported CentOS realease 5.6 (Final).  The release versions showed identical as per this file, yet the behaviors were very different.

/etc/redhat-release is a file in the yum package centos-release-5-6.el5.centos.1 .  If you install that package the release version will change to the file inside the package, regardless of the other packages, drivers, etc, that would make up a true 5.6 release level.  You cannot count on /etc/release to determine the distro release level with complete accuracy either.

Jeff Huckaby commented on How To Determine CentOS or Red Hat Version

Jeff Huckaby · 04/11/2011 04:31 pm

@Ronald @Romones  
Certainly if you manually install updates outside of the normal release process, the release file and system assets will diverge.  In practice, we do not do this, so we really do not consider it too much; however, I have ran into systems where people have picked various updates from later releases and installed them. 

In these cases, we just make sure the required components for whatever we are trying to install/maintain are appropriate, e.g. glibc versions, kernel versions, drivers, etc.

Ronald Watson commented on How To Determine CentOS or Red Hat Version

Ronald Watson · 04/12/2011 12:08 am

@Jeff

Actually it happens even WITHIN the normal release process.  I’ve only used the CentOS repos to update my system via yum and I NEVER performed an upgrade on this VM, yet the release level changed.

Since this was clean system and was only using the default CentOS repositories, I must respectfully disagree with you.  In any case, due to erroneous package management from the distro maintainers or the admin’s meanderings, /etc/redhat-release is not an accurate determination of the release level either.

Regards…

Ronald Watson commented on How To Determine CentOS or Red Hat Version

Ronald Watson · 04/12/2011 12:23 am

BTW….
In CentOS there is no
/etc/centos-release.  The filename is still /etc/redhat-release and is part of the yum package centos-release-5-6.el5.centos.1.  This package is also apparently in the CentOS 5.5 repo.

Hope it helps…

Jeff H. commented on How To Determine CentOS or Red Hat Version

Jeff H. · 04/12/2011 09:14 am

@Ronald
Using yum to upgrade your system is what I would consider the normal process.

I have seen people download and manually install RPMs.  You can get divergence that way.

There are no real checks for what is in the /etc/*release files.  So they can give you mis-information. 

But with our management procedures, this is rarely issue over the 100’s of systems we touch every month.

Also, I think CentOS 6 will have /etc/centos-release.

Ravi commented on How To Determine CentOS or Red Hat Version

Ravi · 08/15/2011 05:24 am

thanks so much..!!!

cat /etc/*release*  works fine with Centos 5.4

Jaime commented on How To Determine CentOS or Red Hat Version

Jaime · 11/17/2011 02:18 pm

In 2011, it seems the right way to go is
$>lsb_release -a

(-a is for “all”, man lsb_release for details)

Add Comment

Notify me of comments?

SUBSCRIBE

rackAID Server Management Blog RSS Feed Follow rackAID Server Management on Twitter I Like rackAID's Server Help Contact rackAID about IT Support

Recent Blog Posts

Our Blog