Yin and Yang

CHARLES AUER (dot) NET

Custom Message of the Day

This script should work on any distro based on Debian, but I have only tested it on Ubuntu 10.04 and Ubuntu 12.04. In order to get it to run, you can add it to the end of ~/.bashrc like so:

/path/to/script

Note: The update notification part of the script depends on having the "update-notifier-common" package installed. If it's not installed, you can remove those lines.

Here's the script: (source)

#!/bin/bash

### motd.sh
### Displays some info about the system.
### Created by Charles Auer
### Tested 4/07/2011
### Updated 4/07/2011

echo -e "
 System Information as of $(/bin/date)

 Hostname:      $(/bin/hostname)
 Load Average:  $(/bin/cat /proc/loadavg | /usr/bin/cut -d " " -f 1)
 Processes:     $(/bin/ps aux | /usr/bin/wc -l)
 Memory Free:   $(/usr/bin/free -m | /bin/grep - | /usr/bin/awk '{ print $4 }')MB
 IP Address:    $(/sbin/ifconfig eth0 | /bin/grep "inet addr" | /usr/bin/cut -d ":" -f 2 | /usr/bin/  cut -d " " -f 1)
 Uptime:        $(/usr/bin/uptime | /bin/sed 's/.*up \([^,]*\), .*/\1/')

 $(/usr/lib/update-notifier/apt_check.py --human-readable | grep updated)
 $(/usr/lib/update-notifier/apt_check.py --human-readable | grep security)
"

This is what it outputs:

 System Information as of Mon Mar 14 23:18:53 PDT 2011

 Hostname:      lucid
 Load Average:  0.77
 Processes:     185
 Memory Free:   114MB
 IP Address:    192.168.1.32
 Uptime:        11 days

 2 packages can be updated.
 0 updates are security updates.