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.

Andres
Friday, July 30, 2004


/proc/version

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

Michael,

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

moseswhitecotton
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*.

gd
Friday, July 30, 2004

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

/etc/lsb-release

james
Friday, July 30, 2004

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

Matt
Saturday, July 31, 2004

*  Recent Topics

*  Fog Creek Home