Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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


Do not run this command to 'test' it unless you are prepared for a crash and/or force-rebooting your system.

I was in my Virtualbox running 12.04 trying to compile an app, and while waiting I happened to chance upon a forum where a comment said:

Try :(){ :|: & };:
Fun, too, and doesn't need root.

Without thinking, I ran it in my gnome-terminal. It made my 12.04(in Virtualbox) lag so badly, I had to shut it down.

My question is what does this command do?

:(){ :|: & };:
share|improve this question
related How to protect Ubuntu from fork bomb – Sathya Jul 4 '12 at 11:35
Also see an old thread: – Paddy Landau Jul 10 '12 at 6:17
possible cross site duplicate of:… – Ciro Santilli 巴拿馬文件 六四事件 法轮功 Aug 21 '14 at 21:21
"lag so badly" is pretty optimistic. – pstadler Jun 2 '15 at 9:08
up vote 239 down vote accepted

This is called a fork bomb.

:() means you are defining a function called :

{:|: &} means run the function : and send its output to the : function again and run that in the background.

The ; is a command separator, like &&.

: runs the function the first time.

Essentially you are creating a function that calls itself twice every call and doesn't have any way to terminate itself. It will keep doubling up until you run out of system resources.

Running in Virtualbox was quite sensible really otherwise you would have had to restart your pc.

share|improve this answer
This answer seems to suggest that rebooting is the only recourse. But in fact this fork bomb can be killed without rebooting, and I’ve actually observed that it doesn’t work properly on some systems anyway (because their spawn limit is set sensibly). – Konrad Rudolph Jul 4 '12 at 14:07
Actually, for a full explanation this should probably mention that ; is a command separator. The { ... } part is simply the content of the function. – Michael Kjörling Jul 4 '12 at 14:08
@MichaelKjörling +1 I didn't even understand the syntax until I took into consideration your comments. – jumpnett Jul 11 '12 at 23:39
@SuperMatt I dont know if this question is still active, but anyway I wanted to know what does | and & do. I understand you have provided the working of the function but I wanted to do know what these two do – Noober Sep 26 '15 at 8:31
@Noober if your still wondering (as am I in this black hole of terse and cryptic documentation that is linux) I know! | is a pipe it is put after a command to send that commands output as the input to the command that follows. & is a fork it creates a new thread for the preceding command leaving the current thread to continue executing more commands – flurbius Mar 24 at 6:41

This is a so called fork bomb implemented in shell.

from wikipedia:

:(){ :|:& };:
\_/| |||| ||\- ... the function ':', initiating a chain-reaction: each ':' will start    two more.
 | | |||| |\- Definition ends now, to be able to run ...
 | | |||| \- End of function-block
 | | |||\- disown the functions (make them a background process), so that the children    of a parent
 | | |||   will not be killed when the parent gets auto-killed
 | | ||\- ... another copy of the ':'-function, which has to be loaded into memory.
 | | ||   So, ':|:' simply loads two copies of the function, whenever ':' is called
 | | |\- ... and pipe its output to ...
 | | \- Load a copy of the function ':' into memory ...
 | \- Begin of function-definition
 \- Define the function ':' without any parameters '()' as follows:
share|improve this answer

That command is a well known version of the fork bomb

fork bomb pic from wikipedia

It causes your computer to run out of memory by forking a process infinitely. There exist some safeguards you can use against it as well:

Unix-type systems typically have a process-limit, controlled by a ulimit shell command or its successor, setrlimit. Linux kernels set and enforce the RLIMIT_NPROC rlimit ("resource limit") of a process. If a process tries to perform a fork and the user that owns that process already owns RLIMIT_NPROC processes, then the fork fails. Additionally, on Linux or *BSD, one can edit the pam_limits config file /etc/security/limits.conf to the same effect. However, not all distributions of Linux have the pam_limits module installed by default.

share|improve this answer

According to this :(){ :|: & };: is called

Forkbomb is a kind of poetic virus creator

...The devious little program commands it to make multiple copies of itself, setting off a chain reaction and thus quickly exhausting the system’s resources...

So advised not to run this, could cause damage to hardware since it causes loopwise execution, may cause heating easily in laptops.

Another link explains through screen shots here.

share|improve this answer
If a fork bomb causes hardware damage, then you have a much bigger and deeper problem. – Michael Kjörling Jul 4 '12 at 14:15
Maybe he was talking about a bomb with shape of fork that can explode near your PC ? – dysoco Jul 4 '12 at 18:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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