ISO27001:2013
Certified Supplier

FIND OUT MORE

We're an ISO27001:2013 Certified Supplier

blog-post-featured-image

Most major Linux installations include some facility for working out which version of which distribution they are. Often this is a file in the /etc directory; for example, on a Red Hat Enterprise Linux (RHEL) system it’s /etc/redhat-release:

CentOS, being based on RHEL, uses the same file. The contents of the equivalent file on a Debian system, /etc/debian_version, are much more terse:

That’s factual, but it doesn’t elaborate on what that means. Whereas RHEL includes the codename of the release, “Santiago”, Debian assumes you know that 9.5 is known internally as “Stretch”.

Ubuntu can be even more confusing. Like CentOS, it’s a distribution derived from a parent, in this case Debian:

Here, the version of Ubuntu in use was released while the parent Debian distribution on which it is based was “still in development” (“sid”). The file doesn’t tell us what the actual Ubuntu release was called at all.

A standard interface

Fortunately, it’s standards-to-the-rescue. The Linxu Standard Base (“LSB”) standard defines the program lsb_release which should give consistent and useful information. Here is its output on a Ubuntu system, and you’ll probably agree it’s much more helpful than /etc/debian_version:

The options used:

-c – Display the code name of the currently installed distribution.
-d – Display a description of the currently installed distribution.
-i – Display the distributor’s ID.

Putting it to work

This lends itself very well to scripting. Consider the challenge of installing the Apache web server on a collection of servers, some Red Hat and some Debian. The package name differs, as does the package manager used to install it, but that’s easily accommodated:

What’s your favourite Linux Tip?

Drop us mail, and maybe we’ll feature your tip in future.

Leave a Reply

Your email address will not be published. Required fields are marked *