The Filesystem Hierarchy Standard has a standard definition for /etc/os-release
, which should be available on most distributions:
The /etc/os-release and /usr/lib/os-release files contain operating system identification data.
The basic file format of os-release is a newline-separated list of environment-like shell-compatible variable assignments. It is possible to source the configuration from shell scripts.
This means you can just source /etc/os-release
and use $NAME
or $ID
to identify the distribution. As an example, on Fedora it looks like this:
% source /etc/os-release
% echo $NAME
Fedora
% echo $ID
fedora
On Debian:
% source /etc/os-release
% echo $NAME
Debian GNU/Linux
% echo $ID
debian