So there I was, casually doom-scrolling through a Linux forum (as one does when your OS breaks every other day), trying to fix yet another mysterious issue on my Ubuntu setup. And then—bam!—I stumble upon this emoji-looking Bash spell:
1
:(){ :|:& };:
Now, I get real curious when I see something that looks like a cross between a frowny face and some forbidden shell magic. My inner voice? It’s like:
“Go on, run it. What’s the worst that could happen?”
Spoiler alert: Everything.
Everything is what happens.
Next thing I know, my system goes full potato mode and crashes straight into the BSOD—no, not the Windows Blue Screen of Death (we all hate Windows, right?), but the Linux Black Screen of Doom™. And there I was, staring blankly at my screen, regretting all my life choices—especially that one line.
So in this blog post, I’m going to show you what that cursed script does, how it works, and—hopefully—how not to nuke your system like I did. This is your one-stop guide to understanding one of the most elegant and chaotic Bash scripts ever written.
Let me firstly break down this code:
1
:() { :|:& };:
Part | What it does |
---|---|
:() |
Defines a function named : (yes, a colon—totally valid in Bash) |
{ : | :& }; |
The body of the function: |
- : | : → Calls itself twice, piping one call into another |
|
- & → Runs each call in the background |
|
- ; → Ends the function |
|
: |
This last colon calls the function and starts the bomb |
:()
— Function DefinitionThis defines a Bash function called :
. Weird, but legal. You could name it bob()
and it would behave the same way. It’s just using a single colon for fun (and confusion).
{ :|:& }
— Function BodyThis is where the magic (and disaster) happens:
:|:
— The function calls itself twice, piping one instance into another. This isn’t really about data — it’s about spawning processes.&
— Runs the function in the background, so it doesn’t wait for each call to finish.;
— Closes the function body.:
— Function ExecutionAfter defining it, this last colon invokes the function. And then… boom.
The script rapidly spawns processes, each spawning two more, and so on, until your system runs out of process slots (or memory), and grinds to a halt. This is called a fork bomb—it essentially “explodes” the process table.
Warning: Never run this on a system you care about!
The fork bomb will render your system unusable until you reboot, and you may lose unsaved work.