the most awesome guy ever.

The Blog of Darryl E. Clarke

  Random musings from a jaded coder who just needs a hug.

Linux

General Linux Stuff

Things that I need to document about linux will go here.

Current Distribution of Choice:

Ubuntu: Why? It’s fairly simple, clean, well supported and a little bit further ahead than my previously used Debian Linux. Not to be confused, since it is a dirivitive of Debian and relies heavily on Debian’s repository for resource. I still like Debian and everything they stand for. Just now, Ubuntu is more for my desktop.

To Forward mbox Email to another Address

cat mbox | formail +1 -ds sendmail -oem recipient@add.re.ss

Search & Replace in Text Files

perl -pi~ -e 's/foo/bar/' [files]

This uses Perl regular expresssions. Where foo is what to find, bar is what to replace it with and [files] is the files to work with. This also creates backup files with ~ appended.

Random Stuff To Check and Restart a Process

#!/bin/sh
SERVICE='/usr/bin/application-to-check'
 
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
    echo "$SERVICE service running, everything is fine"
else
    echo "$SERVICE is not running, starting it."
    $SERVICE
    echo "$SERVICE was not running!" | mail -s "$SERVICE was restarted" root
fi