Fog Creek Software
Discussion Board

Determining Linux flavours from scripts

I have some scripts running in Linux and I need to determine the Linux flavour (RH EL/SuSE) in which it is running. Can anyone suggest a reliable way for determining this ? Using "uname" doesn't seems to be a reliable way.

Niranjan Mahapathra
Friday, July 30, 2004

If it is Red Hat or Mandrake, there should be a file '/etc/redhat-release' with the info.

Friday, July 30, 2004


contains system version and distribution name.

so from a shell script it is probably something like

local is_redhat=`cat /proc/version | grep Redhat | wc -l`
etc etc.

Michael Moser
Friday, July 30, 2004


IMHO /proc/version works until You rebuild the kernel (security patch, for example). Am I wrong?

V. Sannikov
Friday, July 30, 2004

dont know if its bulletproof but I use
cat /etc/issue

Friday, July 30, 2004

>  /proc/version works until You rebuild the kernel

don't know, for me it didn't, even after kernel rebuilds - i.e. when you take the sources from the distribution as a baseline.

Michael Moser
Friday, July 30, 2004

There is no way to reliably determine this.

Ask yourself why you need to know. If you need to know because things are in different locations between distros, then just check for the locations of those things instead.

If, however, you are just collecting statistical data, try *asking the user*.

Friday, July 30, 2004

recent versions of linux distributions that conform to the LSB place this information in a standardized place:


Friday, July 30, 2004

Isn't this what all that horrific GNU Autoconf crap is supposedly good for?

Saturday, July 31, 2004

*  Recent Topics

*  Fog Creek Home