How a 13-Character Fork Bomb Crashes Linux and How to Prevent It
This article explains the 13‑character Linux fork bomb created by Jaromil, shows how it rapidly exhausts system resources causing a crash, demonstrates its impact on a cloud VM, and provides practical prevention methods using ulimit and limits.conf.
In 2002 Jaromil designed an extremely compact Linux fork bomb consisting of only 13 characters. When executed, it defines a function and recursively spawns processes, quickly exhausting system resources and causing the system to crash.
Because the function keyword can be omitted in the shell, the 13 characters represent a function definition and its invocation. The core payload is
: |: &, which recursively forks processes via background execution and pipes, causing geometric growth of processes.
Running the bomb on a 2 GB cloud VM demonstrates the effect: after a few seconds the system reports -bash: fork: Cannot allocate memory and becomes unresponsive, requiring a forced reboot.
The fork bomb creates a denial‑of‑service condition by exhausting CPU and memory, and it can be launched without root privileges.
Prevention can be achieved by limiting the number of processes a user may create. Using ulimit -a shows the current limits, and setting ulimit -u 20 restricts a user to 20 processes. For a permanent solution, add a line such as ubuntu - nproc 20 to /etc/security/limits.conf. After applying the limit, the bomb fails with -bash: fork: retry: No child processes, indicating the restriction is effective.
Reference: http://en.wikipedia.org/wiki/Fork_bomb
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
