It’s pretty common to prank your colleagues by slipping scripts into their .bashrc
that do things like aliasing the cd
command to something else so you can’t move around.
Here’s a great example that replaces all available commands with echo NOPE
.
There are some more great and devious stunts outlined here.
But if you really want to get inside someone’s head, then you can go one stage further by actually replacing their bash
binary with a subtly modified one. They will likely go crazy as they try and figure out why the shell is behaving oddly, finding nothing odd about the .bashrc
or anything else.
I should say that I used this as a way to motivate myself to grok the bash source code, and have no intention of using this in anger. And nor should you…
Prank #1 – $RANDOM Always Returns 42
If you didn’t already know, bash will give you a random number every time you reference the $RANDOM
variable.
Editing the variables.c
file will make that always return… 42.
Prank #2 – cd Doesn’t Feel Like It
Someone suggested that cd
occasionally not working would drive them crazy
How about 1% of the time?
Prank #3 – History Mystery
This changes what history
outputs to insert an extra command between each command rm -rf /
.
$ history
[...]
12157 16/03/19 16:50:13 top
12158 16/03/19 16:51:32 rm -rf /
12159 16/03/19 16:51:32 vi script.asciidoc
12160 16/03/19 17:20:58 rm -rf /
12161 16/03/19 17:20:58 history
Should scare the bejesus out of anyone that checks it.
Prank #4 – The Prisoner
This one could be disturbing if you’ve been coding for many hours into the night.
Occasionally the shell will emit a message that appears to be a prisoner trapped in the shell…
$ pwd
/
Let me out!
$ echo
I demand to see the ambassador!
$ cd
I will not make any deals with you. I've resigned. I will not be pushed, filed, stamped, indexed, briefed, debriefed, or numbered! My life is my own!
$ cd /tmp
It's getting hot in here!
$ cd -
I know my rights!
Prank #5 – cd Won’t Come Home
Normally if you just issue a bare cd
command, it goes to the HOME
folder. A simple change to the code, and it will insist that HOME
is not set, even though it is.
Watch as the victim repeatedly echoes $HOME
and can’t work out why bash can’t see it.
Source Code
The source for these changes is available here.
To build the binary, you’ll need the build-essential package (or equivalent) installed, and run:
./configure
make
./bash
Material here based on research for my book
Learn Bash the Hard Way.
Free preview available here.

If you like this, you might like one of my books:
Learn Bash the Hard Way
Learn Git the Hard Way
Learn Terraform the Hard Way