fortune (Unix)



fortune is a program that displays a
pseudorandom A pseudorandom sequence of numbers is one that appears to be statistically random, despite having been produced by a completely deterministic and repeatable process. Background The generation of random numbers has many uses, such as for rand ...
message from a database of quotations that first appeared in
Version 7 Unix Seventh Edition Unix, also called Version 7 Unix, Version 7 or just V7, was an important early release of the Unix operating system. V7, released in 1979, was the last Bell Laboratories release to see widespread distribution before the commercial ...
. The most common version on modern systems is the BSD fortune, originally written by
Ken Arnold Kenneth Cutts Richard Cabot Arnold (born 1958) is an American computer programmer well known as one of the developers of the 1980s dungeon-crawling video game '' Rogue'', for his contributions to the original Berkeley (BSD) distribution of Un ...
. Distributions of fortune are usually bundled with a collection of themed files, containing sayings like those found on
fortune cookie A fortune cookie is a crisp and sugary cookie wafer usually made from flour, sugar, vanilla, and sesame seed oil with a piece of paper inside, a "fortune", usually an aphorism, or a vague prophecy. The message inside may also include a Chin ...
s (hence the name), quotations from famous people, jokes, or poetry. As of November 2017, the quotations (with the exception of tips relevant to system operation) have been removed from FreeBSD entirely after user complaints regarding quotations from
Adolf Hitler Adolf Hitler (; 20 April 188930 April 1945) was an Austrian-born German politician who was dictator of Nazi Germany, Germany from 1933 until Death of Adolf Hitler, his death in 1945. Adolf Hitler's rise to power, He rose to power as the le ...
being contained in some of the files. fortune is predominantly found on Unix-like systems, but clients for other platforms also exist. Often, users on text-mode Unix terminals will place this command into either their .profile or .logout files to display them at logon and logout, respectively. It is also used to generate text input for certain
XScreenSaver XScreenSaver is a free and open-source collection of 240+ screensavers for Unix, macOS, iOS and Android operating systems. It was created by Jamie Zawinski in 1992 and is still maintained by him, with new releases coming out several times ...
modes. It is possible to pipe fortune into the cowsay command, to add more humor to the dialog.


Most Unix systems use fortunes which are slanted heavily toward the user base of Unix, and thus contain many obscure jokes about
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includin ...
and computer programming. Other favoured sources include quotations from
science fiction Science fiction (sometimes shortened to Sci-Fi or SF) is a genre of speculative fiction which typically deals with imaginative and futuristic concepts such as advanced science and technology, space exploration, time travel, parallel univers ...
Star Trek ''Star Trek'' is an American science fiction media franchise created by Gene Roddenberry, which began with the eponymous 1960s television series and quickly became a worldwide pop-culture phenomenon. The franchise has expanded into vario ...
'', '' The Cyberiad'', ''
Doctor Who ''Doctor Who'' is a British science fiction television series broadcast by the BBC since 1963. The series depicts the adventures of a Time Lord called the Doctor, an extraterrestrial being who appears to be human. The Doctor explores the ...
'', ''
The Hitchhiker's Guide to the Galaxy ''The Hitchhiker's Guide to the Galaxy'' (sometimes referred to as ''HG2G'', ''HHGTTG'', ''H2G2'', or ''tHGttG'') is a comedy science fiction franchise created by Douglas Adams. Originally a 1978 radio comedy broadcast on BBC Radio 4, it ...
'', etc.),
Zippy the Pinhead Zippy the Pinhead is a fictional character who is the protagonist of ''Zippy'', an American comic strip created by Bill Griffith. Zippy's most famous quotation, "Are we having fun yet?", appears in '' Bartlett's Familiar Quotations'' and became ...
, and the writings of
Ambrose Bierce Ambrose Gwinnett Bierce (June 24, 1842 – ) was an American short story writer, journalist, poet, and American Civil War veteran. His book ''The Devil's Dictionary'' was named as one of "The 100 Greatest Masterpieces of American Literature" by t ...
Dave Barry David McAlister Barry (born July 3, 1947) is an American author and columnist who wrote a nationally syndicated humor column for the ''Miami Herald'' from 1983 to 2005. He has also written numerous books of humor and parody, as well as comic ...
. Most fortune collections also include a wide variety of more conventionally sourced quotations, jokes, and other short passages. A few distributions include "offensive" dicta, which require the -a or -o options to be passed for viewing. These fortunes often include rude humor and profanity, personal attacks, and controversial comments about religion. Sometimes they are provided by another package, however as of FreeBSD 10.0 the offensive dicta have been removed completely. The exact fortunes vary between each type of Unix, however there seems to be a strong overlap between the
FreeBSD FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution (BSD), which was based on Research Unix. The first version of FreeBSD was released in 1993. In 2005, FreeBSD was the most popular o ...
OpenBSD OpenBSD is a security-focused, free and open-source, Unix-like operating system based on the Berkeley Software Distribution (BSD). Theo de Raadt created OpenBSD in 1995 by forking NetBSD 1.0. According to the website, the OpenBSD project empha ...
fortune files. The Plan 9 fortune files seem to be much shorter, with many just on 1 line, and the 'offensive' dicta is much stronger. Most Linux distributions, such as Debian (and its derivatives), choose the FreeBSD fortunes to put in their fortune packages, that can be installed through the package manager.


One of the included fortunes, from the "goedel" collection of fortunes about fortune itself, sums up the purpose of the program: The original fortune program could be used for the more general task of picking up a random line from a plain-text file. The example of such use is given in th
rc documentation
However, in most modern Unix systems fortune cannot be used this way, since they use an ad hoc file format for fortune files to allow multiline aphorisms.

Fortune files

Conventional versions of fortune use two files for each quotation list: a text file with quotations, each separated by the character "%" on its own line, and a random-access data file generated by the strfile(1) program. Alternative implementations, including those made for display on Web pages, typically use only the text file.

Common options

Several common options exist that change the way command-line versions of fortune behave:

See also

QOTD The Quote of the Day (QOTD) service is a member of the Internet protocol suite, defined in RFC 865. As indicated there, the QOTD concept predated the specification, when QOTD was used by mainframe sysadmins to broadcast a daily quote on request by ...


External links

* *
A PHP version of the fortune program

The manual page for the original Unix fortune(6) command

Maintenance version of fortune-mod's source code
- on
GitHub GitHub, Inc. () is an Internet hosting service for software development and version control using Git. It provides the distributed version control of Git plus access control, bug tracking, software feature requests, task management, conti ...
with new releases ** – source code for fortune-mod program
A wiki containing all of the original non offensive fortunes

A modern, color-terminal oriented fortune database

A fortune-mod add on for math-related fortunes

A portable and full implementation in Python
distributed with all th
historical cookie files
{{Plan 9 commands 1979 software Unix software Novelty software Free and open-source Android software Plan 9 commands