Nifty get version script for Linux/Unix

Here’s a simple script I created that grabs all package information from a system, then outputs it to a comma delimited format great for spreadsheets. I grabbed a portion of code from novel’s OSdetech script so this will work on many different Linux distributions


#!/bin/bash script by smelendy for umw.
#purpose: grab version info for servers
#OSdetect portion from

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

VERSION=`cat $1 | tr “\n” ‘ ‘ | sed s/.*VERSION.*=\ // `
if [ "${OS}" = "SunOS" ] ; then
ARCH=`uname -p`
OSSTR=”${OS} ${REV}(${ARCH} `uname -v`)”
pkginfo -l |egrep “PKGINST|NAME|VERSION”
elif [ "${OS}" = "Linux" ] ; then
KERNEL=`uname -r`
if [ -f /etc/redhat-release ] ; then
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
yum list | awk ‘{print $1, “, version ” $2}’
elif [ -f /etc/debian_version ] ; then
DIST=”Debian `cat /etc/debian_version`”
dpkg –list | awk ‘{print $2, “, version ” $3}’
echo ${OSSTR}

echo Version report of `hostname` on ${OSSTR} system has successfully completed on `date`


example how to run >  textfile.csv


More Scripts and other tips coming soon,


Posted in Uncategorized | Comments Off

Hello world!

Welcome vistors! This is the first of hopefully many posts to come. This site will provide tales of my many adventures of being a systems administrator here at the University of Mary Washington. Till next time.

Posted in Uncategorized | 1 Comment