Install
# RHEL / Alma / Rocky (often via EPEL) sudo dnf install epel-release sudo dnf install fortune-mod # Debian / Ubuntu sudo apt install fortune-mod fortunes # openSUSE sudo zypper install fortune # Arch sudo pacman -S fortune-mod
What it does
fortune prints a randomly selected quote from “fortune files”. It’s often used for a little terminal personality (login message, shell startup, MOTD), or piped into other fun tools like cowsay.
How it works (mechanical)
- Reads precompiled “fortune database” files (typically under
/usr/share/games/fortunes). - Selects an entry at random (optionally filtered by length or pattern).
- If the program is installed but you see “no fortunes found”, you likely need to install the fortunes data package too.
Quick Start
# Print a random fortune fortune # Short fortunes only fortune -s # Long fortunes only fortune -l # Pick from a specific fortune file (example) fortune literature
10 Practical Examples
- Basic use
fortune
- Short fortune (good for prompts)
fortune -s
- Long fortune
fortune -l
- Show the source file name
fortune -f
- Pick from one category/file
fortune wisdom
- Match a pattern (regex)
fortune -m 'linux|unix'
- Weight multiple sources
# 80% 'wisdom', 20% 'science' fortune 80% wisdom 20% science
- Pipe into cowsay
fortune | cowsay
- Pipe into lolcat (if installed)
fortune -s | lolcat
- Use at login (bash)
# Add to ~/.bashrc fortune -s
Notes & Gotchas
- “No fortunes found” usually means the quote databases aren’t installed. Install the fortunes data package for your distro.
- Content varies: some fortune sets include jokes, quotes, pop culture, etc. If you’re adding it to login scripts, choose the databases you’re comfortable displaying.
- Determinism: it’s intentionally random; for reproducible output you’d need to control randomness externally.
Historical Context
The original fortune idea comes from classic UNIX/BSD “games” utilities: small programs that add personality and delight to the terminal. On many Linux distributions, the common implementation is fortune-mod, a widely packaged fork/port.
Modern Equivalent
There isn’t a strict “modern replacement” — fortune is already lightweight and still fun. Modern terminal personalization often pairs it with tools like cowsay, prompt frameworks, or MOTD generators.
Related Commands
cowsay— speak the fortune with ASCII art.lolcat— colorize fortune output.figlet/toilet— big banner text for MOTD.motdtooling — distro-specific message-of-the-day scripts.