Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I've found this code in a tweet:

:(){ :|: & };:

It said something about fork, but I don't completely get how it works. Could anybody please explain in detail what it does and how it works? Thanks in advance.

share|improve this question

marked as duplicate by Renan, rahmu, Anthon, slm, jasonwryan May 20 '13 at 18:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 3 down vote accepted

That is a "fork bomb", as you've heard. There's a whole wikipedia page about it.

The fork bomb in this case is a recursive function that runs in the background, thanks to the ampersand operator. This ensures that the child process does not die and keeps forking new copies of the function, consuming system resources. -Wikipedia

In short, what it's doing is it's creating more and more processes (by calling the same function recursively) thereby overloading the system.

You'll note that the function identifier is ":()" which you could replace with a name and indent the code to make it more legible:

By replacing the function identifier and re-indenting, the code reads:

bomb() { 
  bomb | bomb & 

"Don't try this at home kids." -Mr. Wizard

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.