fork-bomb

How to crash your computer

fork-bomb

or what is known as a fork bomb

An insanely simple way to crash your computer from the command prompt.

The Bash command :(){ :|:& };: is a fork bomb — a type of denial-of-service attack that exploits the system by rapidly creating a large number of processes, overwhelming system resources and effectively making the machine unresponsive.

🧨 What the Command Does

:(){ :|:& };:

It defines a function named : that recursively calls itself twice, once in the background, and then executes the function. This leads to exponential growth in the number of processes.

🔍 Breakdown of Each Part

Let’s break it down character by character:

fork-bomb1

1. :()

This defines a function named : (yes, a colon is used as the function name — allowed, though unusual).

It’s the start of a function definition syntax in Bash.

fork-bomb2

2. { :|:& }

The function body. It contains:

: — a call to the function itself (i.e., recursion).

| — pipe: passes the output of the first function call to the input of the next.

: — a second call to the function itself.

& — runs the piped commands in the background, allowing the function to spawn child processes without waiting for them to finish.

fork-bomb3

3. ;

Ends the function definition.

fork-bomb4

4. :

Calls the function for the first time, initiating the fork bomb.

⚠️ Warning

Never run this command on a live or important system. It can lock up your machine requiring a reboot, and may cause data loss if unsaved work is present.

If you’re experimenting in a controlled environment, you should always have:

Process limits (ulimit) set.

Root access disabled if unnecessary.

A method to kill processes (e.g., remote kill script, recovery shell).

Summary

This is a cleverly obfuscated Bash fork bomb that abuses recursive function calls and background processing to quickly exhaust system resources. It’s a classic example of how seemingly simple Bash commands can be extremely powerful — and dangerous.