[ale] Universal way to determine distro?

lists at stromberg.org lists at stromberg.org
Thu Jul 20 17:11:41 EDT 2006


> Good morning,
>
>    I guess this shows my lack of knowledge but is there a
> universal way to determine what distro a particular machine
> is running? I'd like to do this from bash or python, but I
> can't think of nor google anything useful. Any ideas?

Here is one place where the LSB really made a difference. Check out the
lsb_release utility. This is from my ~/.zprofile that displays the distro
I've logged into. The really nasty "else" case is for truly ancient Linux
versions that have no LSB compliance:


if [ -f /etc/lsb-release ]; then
    DISTRO=`lsb_release -i | cut -d: -f2 | sed s/'^\t'//`
    DISTRO_REVISION=`lsb_release -r | cut -d: -f2 | sed s/'^\t//'`
else
    DISTRO=`ls -d /etc/[A-Za-z]*[_-][rv]e[lr]* | grep -v "lsb-release.d" | \
            xargs cat | grep -v "=" | head -n 1 | cut -d\( -f1 | \
            sed s/"Base System version "// | sed s/" release"//`
fi






More information about the Ale mailing list