Get a Random fortune cookie using the Unix fortune command

I have been using linux for more than 3 years, but I still come across some old/legacy applications that I have never even heard of. This time I came to know about the legendary fortune command. All it does is throw some random fortune (quotation) from a huge database on your screen. Before coming to any conclusion about the software, try it out first .

Installation

It is available in the form of fortune-mod package. Install it

[shredder12]$ sudo aptitude install fortune-mod   #ubuntu or debian

[root]# yum install fortune-mod    #fedora or RedHat based systems

Its not all about random message fetching. This database of messages is divided into various categories which are further sub-divided into offensive and non-offensive ones and you can tell the fortune command to run in favour of either of them. Say you want to fetch the epigrams from the category linux.

[shredder12]$ fortune linux

I've seen people with new children before, they go from ultra happy to
looking like something out of a zombie film in about a week.
        -- Alan Cox about Linus after his 2nd daughter

You can even mention multiple categories

[shredder12]$ fortune linux science

They can each be preceded with the probability you want a fortune to be picked from them. Say:

[shredder12]$ fortune 90% linux 10% science

Although, 10% for science was not required, as the rest of the probability (100 - sum of all mentioned) is applied to the rest. You can find the list of categories or files searched in /usr/share/games/fortunes.

For fetching only from offensive databases use the -o option.

[shredder12]$ fortune -o

You can even do pattern searching, using -m. Say you want to read all the fortunes under linux category containing the word 'sex'

[shredder12]$ fortune linux -m sex

(/usr/share/games/fortunes/linux)
%
Software is like sex; it's better when it's free.
        -- Linus Torvalds
%

You can find more about fortune in its man page. Have fun.

1 Comment

Anon Linuxer (not verified)
October 6th, 2010 02:36 pm
Just to mention that in debian at least there are other packages containing fortune databases that you might want to add.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.
  • Search Engines will index and follow ONLY links to allowed domains.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.