Create a custom database for fortune

I’m pretty sure that most linux users are familiar with fortune. I use it for a lot of stuff, such as adding random footer for my email, or providing feed for my plurk-bot.

To install fortune on your ubuntu box, just type:

surfer@m5-m3:~$ sudo apt-get install fortune-mod

To get a random message from fortune, just type:

surfer@m5-m3:~$ fortune 
You will become rich and famous unless you don't.

To get a message from specific database, type:

surfer@m5-m3:~$ fortune startrek
Well, Jim, I'm not much of an actor either.

Fortune default install includes 2 databases. Additional database can be found on ubuntu repositiry. Just open synaptic, and search for “fortune”.


You can create your own fortune database from scratch.

First, go to  the fortune database directory:

surfer@m5-m3:~$ cd /usr/share/games/fortunes/

Create a text file containing the quotes and messages that you want to put to the database file with your preferred text editor. For example, since i want to create a database of quotes from Chuck Palahniuk’s works I’ll name the file “palahniuk”

surfer@m5-m3:~$ sudo nano palahniuk

Make sure that each messages is separated by a “%”. For example:

All God does is watch us and kill us when we get boring. We must never, ever be boring - C.Palahniuk
The one you love and the one who loves you are never, ever the same person - C.Palahniuk
It's only after we've lost everything that we're free to do anything - C.Palahniuk
We all die. The goal isn't to live forever, the goal is to create something that will - C.Palahniuk
Nothing of me is original. I am the combined effort of everyone I've ever known - C.Palahniuk
You realize that our mistrust of the future makes it hard to give up the past - C.Palahniuk

Save the file. To create the database, type:

surfer@m5-m3:~$ sudo strfile palahniuk

And done 🙂 You can now get fortune from your database by typing:

surfer@m5-m3:~$ fortune palahniuk
Nothing of me is original. I am the combined effort of 
everyone I've ever known - C.Palahniuk


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s