/etc/release equivalents for sundry Linux (and other Unix) distributions

These are useful in cross-platform scripts.


Annvix: /etc/annvix-release
Arch Linux: /etc/arch-release
Arklinux: /etc/arklinux-release
Aurox Linux: /etc/aurox-release
BlackCat: /etc/blackcat-release
Cobalt: /etc/cobalt-release
Chakra: /etc/lsb-release
Conectiva: /etc/conectiva-release
Debian: /etc/debian_version, /etc/debian_release (rare)
Fedora / Fedora Core: /etc/fedora-release
FreeEOS: /etc/eos-version
Gentoo Linux: /etc/gentoo-release
HLFS: /etc/hlfs-release, /etc/hlfs_version
Immunix: /etc/immunix-release
IYCC: /etc/lsb-release
Knoppix: knoppix_version
Linux-From-Scratch / LFS: /etc/lfs-release, /etc/lfs_version
Linux-PPC: /etc/linuxppc-release
Linux Mint: /etc/lsb-release
Macintosh OS X: [see below]
Mageia: /etc/mageia-release
Mandrake: /etc/mandrake-release
Mandriva/Mandrake Linux: /etc/mandriva-release, /etc/mandrake-release, /etc/mandakelinux-release
MkLinux: /etc/mklinux-release
Novell Linux Desktop: /etc/nld-release
PLD Linux: /etc/pld-release
RHEL / RHAS / Red Hat Linux: /etc/redhat-release, /etc/redhat_version (rare)
Rubix: /etc/rubix-version
Scientific Linux / ScientificSL / ScientificCERNSLC / ScientificFermiLTS / ScientificSLF: /etc/redhat-release, /etc/redhat_version
Slackware: /etc/slackware-version, /etc/slackware-release (rare)
SME Server (Formerly E-Smith): /etc/e-smith-release
Solaris SPARC: /etc/release
Sun JDS: /etc/sun-release
SUSE Linux: /etc/SuSE-release, /etc/novell-release
SUSE Linux ES9: /etc/sles-release
Synology: /etc/synoinfo.conf
Tiny Sofa: /etc/tinysofa-release
Trustix: /etc/trustix-release, /etc/trustix-version
TurboLinux: /etc/turbolinux-release
Ubuntu Linux: /etc/lsb-release
UltraPenguin: /etc/ultrapenguin-release
UnitedLinux: /etc/UnitedLinux-release (covers SUSE SLES8)
VA-Linux/RH-VALE: /etc/va-release
Yellow Dog: /etc/yellowdog-release

The command "echo /etc/*_ver* /etc/*-rel*; cat /etc/*_ver* /etc/*-rel*" should find any reasonably similar variants.

The /etc/issue and /etc/issue.net files are also often helpful.

Linux System Base-compliant systems should have a file called /etc/lsb_release, which may be in addition to a distribution-specific file.

Many non-Red Hat RPM-based distributions include /etc/redhat-release for compatibility.



Macintosh OS X:

2016 answer: Robert P. Thille points out that the pre-2016 answer below is incorrect/unclued, that /usr/bin/uname on OS X returns "Darwin" as the result and /usr/bin/sw_vers returns several lines of system data including a "ProductVersion" line. He suggests this Bourne shell script:

#!/bin/sh

OS=`uname -s`
REV=`uname -r`
MACH=`uname -m`
# ...
if [ "${OS}" = "Darwin" ]; then
OIFS="$IFS"
IFS=$'\n'
set `sw_vers` > /dev/null
DIST=`echo $1 | tr "\n" ' ' | sed 's/ProductName:[ ]*//'`
VERSION=`echo $2 | tr "\n" ' ' | sed 's/ProductVersion:[ ]*//'`
BUILD=`echo $3 | tr "\n" ' ' | sed 's/BuildVersion:[ ]*//'`
OSSTR="${OS} ${DIST} ${REV}(SORRY_NO_PSEUDONAME ${BUILD} ${MACH})"
IFS="$OIFS"
fi
echo ${OSSTR}

Pre-2016 answer: There are four methods, all of them a bit complicated and having various drawbacks. They are detailed at Cocoa Dev Central.




Sample Script

Using system command "uname" and contents of the release files you can write scripts of programs to help your software to detect distribution.

#!/bin/sh
# Detects which OS and if it is Linux then it will detect which Linux
# Distribution.

OS=`uname -s`
REV=`uname -r`
MACH=`uname -m`

GetVersionFromFile()
{
	VERSION=`cat $1 | tr "\n" ' ' | sed s/.*VERSION.*=\ // `
}

if [ "${OS}" = "SunOS" ] ; then
	OS=Solaris
	ARCH=`uname -p`	
	OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
elif [ "${OS}" = "AIX" ] ; then
	OSSTR="${OS} `oslevel` (`oslevel -r`)"
elif [ "${OS}" = "Linux" ] ; then
	KERNEL=`uname -r`
	if [ -f /etc/redhat-release ] ; then
		DIST='RedHat'
		PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
		REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
	elif [ -f /etc/SuSE-release ] ; then
		DIST=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
		REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
	elif [ -f /etc/mandrake-release ] ; then
		DIST='Mandrake'
		PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
		REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
	elif [ -f /etc/debian_version ] ; then
		DIST="Debian `cat /etc/debian_version`"
		REV=""

	fi
	if [ -f /etc/UnitedLinux-release ] ; then
		DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
	fi
	
	OSSTR="${OS} ${DIST} ${REV}(${PSUEDONAME} ${KERNEL} ${MACH})"

fi

echo ${OSSTR}