Blog / Linux Terminal Games and Easter Eggs
There is a long history of jokes in UNIX and Linux. So, here are some fun programs and Easter Eggs. Most have good manpages, so check those for more CLI flags and such that are not discussed here.
UNIX Games
bsd-games
bsd-games (or something named similarly) is a package for many Linux distros.
It contains a lot of old-school terminal games you can use to waste time,
UNIX mainframe user style.
There's classic ones like snake (called worm),
Tetris (tetris-bsd), and Rogue.
There are a lot of more esoteric text-based adventure games too.
In order to have permissions to play games, you must add yourself to the games
group like so:
$ usermod -g machinefossil games
You can use $ apropos games to see what games you have.
sl
Do you (or a friend you want to prank) ever accidentally misspell ls
as sl? If you install sl, now instead of just getting
an error, you have to wait for a steam locomotive to go by.
There are some flags; -a makes the people in the train scream for help.
-e enables ctrl+C to exit the animation (disabled by default).
$ sl
( ) (@@) ( ) (@) () @@ O @ O @
(@@@)
( )
(@@@@)
( )
==== ________ ___________
_D _| |_______/ \__I_I_____===__|_________|
|(_)--- | H\________/ | | =|___ ___| _________________
/ | | H | | | | ||_| |_|| _| \___
| | | H |__--------------------| [___] | =|
| ________|___H__/__|_____/[][]~\_______| | -|
|/ | |-----------I_____I [][] [] D |=======|____|______________________
__/ =| o |=-~~\ /~~\ /~~\ /~~\ ____Y___________|__|________________________
|/-=|___|=O=====O=====O=====O |_____/~\___/ |_D__D__D_| |_D__D__D
\_/ \__/ \__/ \__/ \__/ \_/ \_/ \_/ \_/ \
Terminal Screensavers
Do you like the movie The Matrix, or do you want to make people
looking over your shoulder think you're Hackerman? cmatrix is
a "screensaver" for your terminal that makes the digital rain effect.
According to the "BUGS" section of the manual, it's also very CPU-intensive
for some reason.
aafire has similar functionality but makes a fire effect,
and rain makes a rain effect.
fortune
Fortune (packaged as fortune-mod on some distros)
is a program that prints out a random string from a string file,
sort of like choosing a random fortune cookie.
It comes with a few files by default, containing mostly UNIX-related jokes
as well as quotes from literature and famous people.
If you like offensive humor, the -o flag enables printing
fortunes from files deemed offensive. (These files are in their own package on some
distros; for example fortunes-off on Debian.)
Some people keep their own quotes file and have their email client configured to append quotes from it into their email signature. Here's how to create a quotes file that fortune can read, and print a quote from it.
-
Enter your strings into a text file. Separate strings with '%' on a line by itself. Here's an example file (containing quotes from Marathon, a 1994 Bungie FPS).
File: marathonquotes.txt
You should not have helped them as much as you did; they have created an adversary more powerful than yourself. % May the best sentience win. % You are not as clever as you imagine. % Prepare for your demise. % FROG BLAST THE VENT CORE!!!! % Smells like napalm, tastes like chicken. % one thousand thousand slimy things % Consider yourself warned.
-
Convert this to a binary string file using the
strfilecommand, like so. The name of the binary file output defaults to "[original filename].dat"$ ls marathonquotes.txt $ strfile marathonquotes.txt "marathonquotes.txt.dat" created There were 8 strings Longest string: 112 bytes Shortest string: 25 bytes $ ls marathonquotes.txt marathonquotes.txt.dat
-
Annoyingly,
fortuneignores the ".dat" extension, so if you type that extension, fortune will return an error instead of printing a quote. Just leave the ".dat" part off.$ fortune marathonquotes.txt.dat fortune:../marathonquotes.txt.dat not a fortune file or directory No fortunes found $ fortune marathonquotes.txt FROG BLAST THE VENT CORE!!!!
-
If you want to see a fortune every time you open a terminal / log in, you can add a fortune command to your
.bashrc. For example, if you wanted one of those Marathon quotes to print, you would add the line highlighted below:File: ~/.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac ... fortune ~/path/to/marathonquotes.txt ...
cowsay
Cowsay prints an ASCII picture of a cow with the input string in a speech bubble.
You can pipe arbitrary text into cowsay to see an ASCII cow saying it.
There are a few flags to change the cow's appearance; -e and -T
change the eyes and tongue, respectively, to the strings following them.
The -f flag can be used to select a different ASCII art character
from the files in /usr/share/cowsay/cows.
$ cowsay hello
_______
< hello >
-------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
$ cowthink -d I\'m dead
__________
( I'm dead )
----------
o ^__^
o (xx)\_______
(__)\ )\/\
U ||----w |
|| ||
$ cowsay -t ...
_____
< ... >
-----
\ ^__^
\ (--)\_______
(__)\ )\/\
||----w |
|| ||
$ cowsay -e @@ -T "U " wow
_____
< wow >
-----
\ ^__^
\ (@@)\_______
(__)\ )\/\
U ||----w |
|| ||
$ fortune | cowsay
____________________________
< Beware the one behind you. >
----------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
$ cowsay -l
Cow files in /usr/share/cowsay/cows:
apt bud-frogs bunny calvin cheese cock cower daemon default dragon
dragon-and-cow duck elephant elephant-in-snake eyes flaming-sheep
ghostbusters gnu hellokitty kangaroo kiss koala kosh luke-koala
mech-and-cow milk moofasa moose pony pony-smaller ren sheep skeleton
snowman stegosaurus stimpy suse three-eyes turkey turtle tux unipony
unipony-smaller vader vader-koala www
$ fortune | cowsay -f tux
___________________________________
< You will outgrow your usefulness. >
-----------------------------------
\
\
.--.
|o_o |
|:_/ |
// \ \
(| | )
/'\_ _/`\
\___)=(___/
toilet
toilet makes big ASCII art text.
The flag --filter applies filters
(such as rotating the text 90 degrees, or applying colors),
while -f changes the ASCII art "font" to a different one
(by default, stored in /usr/share/figlet).
$ toilet GNU/Linux
mmm mm m m m m m "
m" " #"m # # # # # mmm m mm m m m m
# mm # #m # # # # # # #" # # # #m#
# # # # # # # # # # # # # # m#m
"mmm" # ## "mmmm" # #mmmmm mm#mm # # "mm"# m" "m
"
$ toilet --filter list
Available filters:
"crop": crop unused blanks
"gay": add a rainbow colour effect
"metal": add a metallic colour effect
"flip": flip horizontally
"flop": flip vertically
"180": rotate 180 degrees
"left": rotate 90 degrees counterclockwise
"right": rotate 90 degrees clockwise
"border": surround text with a border
$ ls /usr/share/figlet/
ascii12.tlf bigmono9.tlf letter.tlf smascii9.tlf wideterm.tlf
ascii9.tlf circle.tlf mono12.tlf smblock.tlf
bigascii12.tlf emboss2.tlf mono9.tlf smbraille.tlf
bigascii9.tlf emboss.tlf pagga.tlf smmono12.tlf
bigmono12.tlf future.tlf smascii12.tlf smmono9.tlf
$ toilet --filter border -f wideterm vaporwave
┌──────────────────┐
│vaporwave│
└──────────────────┘
lolcat
lolcat is like the UNIX command cat except with rainbow output.
Check the manpage for options regarding the randomization and spread of colors.
The flag -a will make each line flash rainbow colors before
the next one is printed.
$ fortune marathonquotes.txt | cowsay -f tux | lolcat
yes
Try this:
$ yes
Then this:
$ yes KILL YOU
All it does is print the input text in an infinite loop, but it can actually be useful. For example, piping into an installer that asks a ton of yes/no questions, or for helping with testing code.
Easter Eggs
apt
If your version of apt has super cow powers (check $ apt --help),
you can summon a cow in order to moo.
$ apt --help | grep -i cow
This APT has Super Cow Powers.
$ apt moo
(__)
(oo)
/------\/
/ | ||
* /\---/\
~~ ~~
..."Have you mooed today?"...
aptitude
Aptitude does not have super cow powers, so you have to try harder to get it to moo.
$ aptitude moo
There are no Easter Eggs in this program.
$ aptitude -v moo
There really are no Easter Eggs in this program.
$ aptitude -vv moo
Didn't I already tell you that there are no Easter Eggs in this program?
$ aptitude -vvvvv moo
All right, you win.
/----\
-------/ \
/ \
/ |
-----------------/ --------\
----------------------------------------------
$ aptitude -vvvvvv moo
What is it? It's an elephant being eaten by a snake, of course.
GCC 1.17 g++
Many programming language specs have "undefined behavior." That is, it's possible to write source code where the behavior of compiler output generated from it could be anything, because the language spec doesn't say what should be done. This might sound like a mistake, but it's just a consequence of not being able to write rules for every single possible scenario that might exist.
In the C++ compiler that was part of GCC 1.17, if a #pragma
was not implemented, the "implementation" would be code that
tries to launch Hack, Rogue, and Towers of Hanoi.
If all three fail, the error message is,
"You are in a maze of twisty compiler features, all different."
You probably won't experience this for yourself anytime soon because
GCC 1.17 was released in 1988.
(stolen from "GCC Easter Egg: C++ Undefined Behavior" by Feross Aboukhadijeh)
python
Python 3 has a few just-for-fun import statements.
For instance, importing antigravity will open
this XKCD strip in your browser.
$ python3 Python 3.7.1 (default, Nov 17 2018, 16:20:23) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import __hello__ Hello world! >>> import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. ...
sudo
sudo can be configured to insult sudoers when they mistype their password.
Run $ sudo visudo to edit the sudoers file safely, and add a line with the following:
Defaults insults
vim
There are many, many vim commands.
:Ni! displays, "Do you demand a shrubbery?"
Some of the help entries are humorous (try these):
:help!:help 42:help bar:help howdoi:help map-modes:help UserGettingBored
offensive USE Flag
If you're using portage on Gentoo, the USE Flag "offensive" enables offensive fortunes and turns on sudo insults, as well as adult content in some games. It's not really an Easter Egg because it's a useful feature, but it's funny.
This article is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.