Answers to: How can I programatically determine the Linux distribution?http://linuxexchange.org/questions/2632/how-can-i-programatically-determine-the-linux-distribution<p>There are various ways of finding out what Linux distribution is currently running, using commands such as:</p> <pre><code>uname -a cat /etc/*-release cat /etc/*-version lsb_release -ri </code></pre> <p>Each of them provides me with <em>human-readable</em> information about my system, but they don't seem reliable nor can be easily parsed. Is there some script that can determine popular Linux distributions with accuracy and output something simple like <code>Ubuntu</code> / <code>Slackware</code> / <code>CentOS</code> / <code>Mandriva</code> / etc?</p>enTue, 16 Jul 2013 04:03:34 -0400Answer by amcohenhttp://linuxexchange.org/questions/2632/how-can-i-programatically-determine-the-linux-distribution/3133<p>Here's a skeletan of a Korn/Bash function to do it:</p> <p>function get_distro { if [[ -r /etc/redhat-relase ]]; then set -- $(cat /etc/redhat-relase) case $1 in Red) echo Redhat;; Fedora) echo Fedora;; CentOS) echo CentOS;; *) echo ??? esac elif [[ -r /etc/debian_version ]]; then echo Debian else echo UNKNOWN fi }</p>amcohenTue, 16 Jul 2013 04:03:34 -0400http://linuxexchange.org/questions/2632/how-can-i-programatically-determine-the-linux-distribution/3133Answer by Jazzhttp://linuxexchange.org/questions/2632/how-can-i-programatically-determine-the-linux-distribution/2639<p><a href="http://www.novell.com/coolsolutions/feature/11251.html">Here's</a> one. You could enhance this script by first using the other ways of finding out which distribution is running before using uname. A combination of those commands should do the trick for any distribution.</p>JazzWed, 13 Jul 2011 16:04:20 -0400http://linuxexchange.org/questions/2632/how-can-i-programatically-determine-the-linux-distribution/2639Answer by DMonhttp://linuxexchange.org/questions/2632/how-can-i-programatically-determine-the-linux-distribution/2633<p>Not sure what all you want it to show. </p> <p><code>$ lsb_release -is</code> </p> <p>will give you just the Distribution</p>DMonWed, 13 Jul 2011 14:05:34 -0400http://linuxexchange.org/questions/2632/how-can-i-programatically-determine-the-linux-distribution/2633