Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Fortune (Unix)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Unix command to print a random message}} {{refimprove|date=October 2010}} {{lowercase title}} {{Infobox software | name = fortune | logo = | screenshot = | screenshot size = | caption = | author = [[Ken Arnold]] | developer = | released = {{Start date and age|1979}} | latest release version = | latest release date = | programming language = [[C (programming language)|C]] | operating system = [[Unix]], [[Unix-like]], [[Plan 9 from Bell Labs|Plan 9]], [[Inferno (operating system)|Inferno]] | genre = [[Command (computing)|Command]] | license = Plan 9: [[MIT License]] | website = }} '''<code>fortune</code>''' is a program that displays a [[pseudorandom]] message from a database of quotations. Early versions of the program appeared in [[Version 7 Unix]] in 1979.<ref>{{cite web |url= https://www.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/games/fortune.c | title=V7/usr/src/games/fortune.c |publisher=tuhs.org |access-date=2024-02-10}}</ref> The most common version on modern systems is the [[Berkeley Software Distribution|BSD]] <code>fortune</code>, originally written by [[Ken Arnold]].<ref>{{Cite web|url=https://svnweb.freebsd.org/base/head/usr.bin/fortune/fortune/fortune.c?revision=328486&view=markup|title=[base] Contents of /head/usr.bin/fortune/fortune/fortune.c|website=svnweb.freebsd.org|language=en|access-date=2018-09-15|quote=This code is derived from software contributed to Berkeley by Ken Arnold.}}</ref> Distributions of fortune are usually bundled with a collection of themed files, containing sayings like those found on [[fortune cookie]]s (hence the name), quotations from famous people, jokes, or poetry. <code>fortune</code> is predominantly found on [[Unix-like]] systems, but clients for other platforms also exist.<ref>{{Cite web|url=http://fortunes.cat-v.org/|title=Jar of Fortune Files|website=fortunes.cat-v.org}}</ref> Often, users on text-mode Unix terminals will place this command into either their <code>.profile</code> or <code>.logout</code> files to display them at logon and logout, respectively. It is also used to generate text input for certain [[XScreenSaver]] modes. ==Content== Most Unix systems use fortunes which are slanted heavily toward the user base of Unix, and thus contain many obscure jokes about [[computer science]] and [[computer programming]]. Other favoured sources include quotations from [[science fiction]] (''[[Star Trek]]'', ''[[The Cyberiad]]'', ''[[Doctor Who]]'', ''[[The Hitchhiker's Guide to the Galaxy]]'', etc.), [[Zippy the Pinhead]], and the writings of [[Ambrose Bierce]] and [[Dave Barry]].<ref>{{Cite web|url=https://sources.debian.org/src/fortune-mod/1:1.99.1-7/datfiles/|title=Debian Sources: fortune 1:1.99.1-7, "datfiles" folder|website=sources.debian.org|access-date=2018-09-15}}</ref> 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 <code>-a</code> or <code>-o</code> 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.<ref>{{Cite web|url = https://svnweb.freebsd.org/base/head/usr.bin/fortune/datfiles/Makefile?view=log|title = Fortune - removal log|date = 2013-03-12|access-date = 2014-06-14|website = FreeBSD SVN|publisher = FreeBSD|last = |first = }}</ref> 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]] being contained in some of the files.<ref>{{Cite web|url=https://svnweb.freebsd.org/base?view=revision&revision=325828|title=[base] Revision 325828|date=2017-11-14|website=svnweb.freebsd.org|language=en|access-date=2018-04-14}}</ref> The exact fortunes vary between each type of Unix, however there seems to be a strong overlap between the [[FreeBSD]] and [[OpenBSD]] fortune files. The [[Plan 9 from Bell Labs|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 [[List of Linux distributions#Debian-based|derivatives]]), choose the FreeBSD fortunes to put in their fortune packages, that can be installed through the package manager. ==Purpose== One of the included fortunes, from the "goedel" collection of fortunes about <code>fortune</code> itself, sums up the purpose of the program: <kbd>{{Poem quote|text= Has anyone realized that the purpose of the fortune cookie program is to defuse project tensions? When did you ever see a cheerful cookie, a non-cynical, or even an informative cookie? Perhaps inadvertently, we have a channel for our aggressions. This still begs the question of whether the cookie releases the pressure or only serves to blunt the warning signs. Long live the revolution! Have a nice day.}}</kbd> The original <code>fortune</code> program could be used for the more general task of picking up a random line from a plain-text file.<ref>{{Cite web|url=http://plan9.bell-labs.com/sys/doc/rc.html|title=rc documentation|website=plan9.bell-labs.com|author=Tom Duff|quote=First, the program guesses a location (in <code>$lab</code>) using the <code>fortune</code> program to pick a random line from the location list.|archive-url=https://web.archive.org/web/20140908071208/http://plan9.bell-labs.com/sys/doc/rc.html|archive-date=2014-09-08}}</ref> However, in most modern Unix systems <code>fortune</code> 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 <code>fortune</code> 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 <code>strfile</code>(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: {| class="wikitable" |- !Option !Action |- !<code>-a</code> |Choose from all databases, regardless of whether they are considered "offensive" or not |- !<code>-e</code> |Make the probability of choosing a fortune file equal to that of all other files |- !<code>-f</code> |Print out a list of all fortune files that would have been searched, but do not print a fortune |- !<code>-i</code> |When used with <code>-m</code>, make regular expression searching case-insensitive |- !<code>-l</code> |Use only quotations longer than the length specified with <code>-n</code>, or 160 characters if <code>-n</code> is not used |- !<code>-m ''[pattern]''</code> |Print all fortunes matching the [[regular expression]] specified in <code>''[pattern]''</code> |- !<code>-n ''[length]''</code> |Override the length used by <code>-l</code> and <code>-s</code> to determine "long" and "short" messages (default 160 characters) |- !<code>-o</code> |Choose only from "offensive" databases |- !<code>-s</code> |Use only quotations shorter than the length specified with <code>-n</code>, or 160 characters if -n is not used |- !<code>-w</code> |Wait for a period of time before terminating; useful for situations in which a fortune needs to be read before the screen is cleared |} ==See also== * [[QOTD]] ==References== {{Reflist}} ==External links== * {{man|1|fortune|Plan 9}} * {{man|6|fortune|die.net}} * [http://www.fortune.levillage.org/cookies.php A PHP version of the fortune program] * [http://man.cat-v.org/unix_8th/6/fortune The manual page for the original Unix fortune(6) command]. * [https://github.com/shlomif/fortune-mod Maintenance version of fortune-mod's source code] - on [[GitHub]] with new releases ** {{cite web |url=ftp://ftp.ibiblio.org/pub/linux/games/amusements/fortune/ |archive-url=https://web.archive.org/web/20210115202758/ftp://ftp.ibiblio.org/pub/linux/games/amusements/fortune/ |archive-date=2021-01-15 |url-status=dead |title=FTP link |work=ftp.ibiblio.org }} β source code for fortune-mod program * [http://fortunes.pbworks.com/ A wiki containing all of the original non offensive fortunes] * [https://github.com/globalcitizen/taoup A modern, color-terminal oriented fortune database] * [https://github.com/maxieds/math-fortune-mod A fortune-mod add on for math-related fortunes] * [https://github.com/HubTou/fortune A portable and full implementation in Python], distributed with all the [https://github.com/HubTou/fortunes-freebsd-classic classical] and [https://github.com/HubTou/fortunes-historical historical cookie files] {{Plan 9 commands}} [[Category:1979 software]] [[Category:Unix software]] [[Category:Novelty software]] [[Category:Free and open-source Android software]] [[Category:Plan 9 commands]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite web
(
edit
)
Template:Infobox
(
edit
)
Template:Infobox software
(
edit
)
Template:Lowercase title
(
edit
)
Template:Main other
(
edit
)
Template:Man
(
edit
)
Template:Plan 9 commands
(
edit
)
Template:Poem quote
(
edit
)
Template:Refimprove
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Template other
(
edit
)