Smoothwall Firewall project

Tuesday, 7 September 2010

Make using the Command line more fun in Ubuntu

Ubuntu has spawned several really great Linux distributions, and one of the best is Linux Mint. It has always had a feature where-by when you open a command prompt, it displays a simple - often silly - message to brighten up your day before you get stuck in. To be fair this has been around for a long time in the Unix world, but is still funny.Ubuntu doesn't have this turned on by default, so I decided to enable it , and it really isn't that hard, if we borrow a great command from Mint guys.

First you need to install the fortune cookie applications and message files:

sudo apt-get install fortune-mod cowsay

You can test this has installed ok by typing the following:

fortune

and you should get a message displayed.

Next you need to create shell scipt that will do all the hard work for you - borrowed from the Mint guys

sudo vim /usr/bin/ubuntu-fortune

Here is what to put into the file

#!/bin/bash
RANGE=4
number=$RANDOM
let "number %= $RANGE"
case $number in
0)
cow="small"
;;
1)
cow="tux"
;;
2)
cow="koala"
;;
3)
cow="moose"
;;
esac

RANGE=2
number=$RANDOM
let "number %= $RANGE"
case $number in
0)
command="/usr/games/cowsay"
;;
1)
command="/usr/games/cowthink"
;;
esac

/usr/games/fortune | $command -f $cow


Now we need to make this file executable by doing this

sudo chmod +x /usr/bin/ubuntu-fortune


Then last but not least we need to place it into one of the shell script master files so that it gets called every time when you start up a shell script. So edit the following file, and place the command - /usr/bin/ubuntu-fortune - as the last entry in the file.

sudo vim /etc/bash.bashrc

Voila, when you now start a shell terminal , you will have something to laugh at, and you can of course just type the command we created above to get a laugh on got.

Here is an example:



Now there are lots of other fortunes you can install, some of them can be very rude, so be careful, and you can grab these either using apt-get or using the Synaptic package manager.

Have fun.