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.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How a 13-Character Fork Bomb Crashes Linux and How to Prevent It

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

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

linuxfork bombDoSprocess limit
MaGe Linux Operations
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.