Correct way to determine distro version in bash?

Ed Felt edfelt at
Mon Apr 8 16:59:10 MDT 2013

"cat /etc/redhat-release" always works for RHEL, CENTOS and Fedora (at
least for the last 5 to 10 years).  You can also do "uname -a" and then
parse.  There may be a better switch that does just  os info on uname
(check the man page).
On Apr 8, 2013 4:46 PM, "Joseph Hall" <perlhoser at> wrote:

> On Mon, Apr 8, 2013 at 4:30 PM, S. Dale Morrey <sdalemorrey at>
> wrote:
> > This got me thinking, is there a correct way to check this sort of thing?
> > Something that's going to be consistent, at least across direct
> derivations
> > such as RHEL & CentOS?
> If there's one thing that I've discovered, there is nothing that is
> absolutely reliable across every distro. However, looking at
> /etc/*release will get you close.
> --
> "In order to create, you have to have the willingness, the desire to
> be challenged, to be learning." -- Ferran Adria (speaking at Harvard,
> 2011)
> /*
> PLUG:, #utah on
> Unsubscribe:
> Don't fear the penguin.
> */

More information about the PLUG mailing list