LinuxCommandLibrary

hangman

Play the classic word guessing game, Hangman

SYNOPSIS

hangman [-d] [wordlist]

PARAMETERS

-d
    Enable debug mode: reveals the secret word immediately.

wordlist
    Path to custom file with one uppercase word per line (default: /usr/share/games/hangman-words).

DESCRIPTION

The hangman command launches a text-based implementation of the popular Hangman game, originally from BSD Unix games collection. A word is randomly selected from a dictionary file, displayed as underscores (one per letter). Players input letters (a-z) to reveal correct positions. Each wrong guess adds a part to an ASCII-art hangman figure. You have 7 incorrect guesses before losing (the figure completes).

To win, guess all letters or the full word (prompted with '?'). The game tracks high scores based on words guessed per session, saved system-wide. Run without arguments for default play using /usr/share/games/hangman-words (one uppercase word per line). Custom dictionaries enable themed play, e.g., technical terms.

Ideal for terminal fun, quick sessions, or multiplayer alternation. Debug mode reveals the word instantly for testing. Part of bsdgames package on many distros; enhances idle time with simple strategy: prioritize vowels, common consonants.

CAVEATS

Wordlist must contain uppercase words, one per line; score file (/var/games/hangman.scores) may require games group permissions. Limited to 7 errors; no undo.

GAME FILES

/usr/share/games/hangman-words: System word list (thousands of words).
/var/games/hangman.scores: Global high scores.

SCORING

Scores = words guessed / man (stick figure parts used). Top scores persist across sessions.

HISTORY

Debuted in 4.3BSD (1986) as part of the standard /usr/games suite. Ported to Linux via bsdgames/bsdgames packages (e.g., Debian since 1990s). Remains popular for its simplicity and nostalgia.

SEE ALSO

rain(6), worm(6), craps(6), sail(6)

Copied to clipboard