There is a standard "uname" command shell that returns the current platform as a string
To use this in a shell program, a typical stanza might be
#!/bin/sh if [ `uname` = "Linux" ] ; then echo "we are on the operating system of Linux" fi if [ `uname` = "FreeBSD" ] ; then echo "we are on the operating system of FreeBSD" fi
More specific information is available, but unfortunately it depends on the platform. In many versions of Linux (and ISTR, Solaris) there is a file / etc / issue, which has a name and version number for the installed distribution. So ubuntu
if [ -e "/etc/issue" ] ; then issue=`cat /etc/issue` set -- $issue if [ $1 = "Ubuntu" ] ; then echo "we are on Ubuntu version " $2 fi fi
This will give version information
source share