Summary: Shell script for detecting aspects of UNIX OS: version, Linux distribution, clone name, release .
In many shell scripts one can find pieces of code such as:
if [ grep -i centos /etc/redhat-release ]
then
DISTRO=CentOS
else
...
and so on.
It's not difficult task to find what OS/ditsro you are running on, but sometimes it takes couple minutes to remember what is actually different between Debian and Ubuntu to make reliable guess. And it is a repeating task, meaning that couple minutes can be spent more than once.
Meet Sherlock OS
This is a simple shell script to detect UNIX/Linux OS and various aspects of the OS. Especially for Linux: distribution type and derivative (such as CentOS/RHEL or Debian/Ubuntu)
But it is packaged as real Ruby gem (I am mostly developing in Ruby these days), so installation is as simple as gem install sherlock_os
. After you install it you can do it like:
$ sherlock
OS=Linux
MACH=x86_64
KERNEL=2.6.32-5-amd64
DISTRIBUTION=debian
FAMILY=debian
DERIVATIVE=Debian
RELEASE=6.0.6
CODENAME=squeeze
or even
$ eval `sherlock | grep DERIVATIVE`
$
$ echo DERIVATIVE
Debian
Documentation
Available at http://dmytro.github.com/sherlock_os
Source code
http://github.com/dmytro/sherlock_os
Enjoy!
Author
Dmytro Kovalov (dmytro.kovalov@gmail.com)
Source code
- Download sherlock_os in either zip or tar formats ⇒
- Clone sherlock_os with git
$ git clone git://github.com/dmytro/sherlock_os
- or go to sherlock_os's Github repository »