ArticleslgStudy

computer science

Fortune (Unix)

Fortune (Unix) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Fortune (Unix) rather than just read about it. In short: fortune 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.

Key takeaways

  • Fortune (Unix) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Fortune (Unix) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Fortune (Unix) from memory before moving on to harder problems.

Reference excerpt

fortune 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. The most common version on modern systems is the BSD fortune, originally written by Ken Arnold. Distributions of fortune are usually bundled with a collection of themed files, containing sayings like those found on fortune cookies (hence the name), quotations from famous people, jokes, or poetry. fortune is predominantly found on Unix-like systems, but clients for other platforms also exist.

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. 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. 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. 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 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.

Purpose 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. 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

References

External links fortune(1) – Plan 9 Programmer's Manual, Volume 1 fortune(6) – Linux Games Manual 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 with new releases "FTP link". ftp.ibiblio.org. Archived from the original on 2021-01-15. – 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 the classical and historical cookie files

Worked examples

Example 1 — a first encounter with Fortune (Unix)

Start with the simplest possible case. Write down what Fortune (Unix) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Fortune (Unix) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Fortune (Unix) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Fortune (Unix)

In research
Fortune (Unix) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Fortune (Unix) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Fortune (Unix) is common in secondary-school and first-year university syllabi. It links to neighbouring topics 1979 software, Free and open-source Android software, Novelty software, so understanding it makes those chapters shorter.
In everyday life
Look for Fortune (Unix) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Fortune (Unix)” →

How to study Fortune (Unix) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Fortune (Unix) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Fortune (Unix) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Fortune (Unix) in simple terms?

fortune 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.

Why does Fortune (Unix) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Fortune (Unix)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Fortune (Unix).

Tags

  • 1979 software
  • Free and open-source Android software
  • Novelty software
  • Plan 9 commands
  • Unix software

Keep exploring