There are various ways of finding out what Linux distribution is currently running, using commands such as:
Each of them provides me with human-readable 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 |
Not sure what all you want it to show.
will give you just the Distribution That only works on some distributions. For example, CentOS doesn't have the
(13 Jul '11, 14:58)
fardelian
CentOS 6 does. Just tried it on there. But you are correct not every Distro does it the same however lsb seems to be more common in the newest batch of updates.
(13 Jul '11, 15:20)
DMon
Furthermore not all distributions report something useful using lsb_release. My ArchLinux configuration prints "n/a" for example.
(13 Jul '11, 15:58)
Jazz ♦
|
Here's a skeletan of a Korn/Bash function to do it: 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 } |