The UNIX/Linux Fork Bomb

This may look like few emoticons used in a wrong way, but when written in a UNIX shell; this may crash your computer. This is the infamous piece of shell script called “fork bomb”.

Here a function is called recursively and each call forks or creates two child processes which run as background process and cannot be auto killed. This way a large number of processes gets created eating away the system resources and brings the system to halt or crash.

Wiki: “the fork bomb is a form of denial-of-service attack against a computer system which makes use of the fork operation (or equivalent functionality) whereby a running process can create another running process. Fork bombs typically do not spread as worms or viruses; to incapacitate a system, they rely on the (generally valid) assumption that the number of programs and processes which may execute simultaneously on a computer has a limit.”

Understanding fork bomb code

Here is more human readable code:

bomb() {



Well a various other forms of the fork bomb, for other operating systems can be found here.

If you wanna try it out in your machine make sure to go through the prevention techniques mentioned here. Well in most cases a system restart/reboot solves the problem.