Discussion:
How do I discover the Linux distribution installed on a machine?
(too old to reply)
DC
2005-03-10 18:55:43 UTC
Permalink
I've got several Linux machines in my office and I need to be able to find
out programmatically / via script which distro is on the box. Uname was my
first guess, but it only reliably delivers the kernal version, some times
the Distro, and sometimes "unknown" (unhelpful). Any ideas?

Thanks

David
Lew Pitcher
2005-03-10 20:48:52 UTC
Permalink
Post by DC
I've got several Linux machines in my office and I need to be able to find
out programmatically / via script which distro is on the box. Uname was my
first guess, but it only reliably delivers the kernal version, some times
the Distro, and sometimes "unknown" (unhelpful). Any ideas?
There are no *reliable* ways to find out programmatically which
distribution has been installed on a system. There are many *unreliable*
ways to do so, but all involve some amount of guessing or uncertainty.

You can look for the existance of /etc/*release* and /etc/*version*
files; some distributions use these files (various names, like
/etc/slackware-version, etc.) to carry version or release numbers. Most
small distros don't do this, though.

You can also inspect the /etc/motd, /etc/issue, and /etc/issue.net files
as some distros place distribution identifiers in these files. Note that
these files are customizable by the installation, and may no longer
carry their default text, even if they exist and are readable by your
scripts. Note also that the names of these files are somewhat plastic,
as most are assigned by configuration files like /etc/login.defs

Neither of these strategies will give 100% accuracy; you will still get
a number of "unknown" systems, unless your office has refrained from
customizing the systems, and has installed recent 'big name'
distributions instead of older or small name distributions.


- --

Lew Pitcher, IT Specialist, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)

Loading...