4

I just encountered this command on a linux forum online where the author warned that donot try this command for curiosity. So my curiosity comes. What is the meaning of command “:() { :|:& }; :” in shell?

user3872279
  • 1,085
  • 2
  • 9
  • 18

1 Answers1

7

This fork bomb is described here

In bash, a function can be defined

function_name() { ... }

where ... is the implementation or body of the function

:(){ ... }

defines a function named :.

:|:

runs the function within itself - that is recursively, and pipes it's output to another invocation of itself.

 & 

runs the preceding command in the background.

So that gives us :(){:|:&} to define this function

 ;

separates the command defining the function from the following command on the same line (like cd;pwd)

 :

is a final command invocation which starts running the newly defined function.


Normally, I'd hope that per-user limits on processes or other resources would limit the effect of a fork bomb of this sort. Wikipedia has a description of defusing a fork bomb


Addendum: After writing this answer I noticed this question was a duplicate of

Other related questions

RedGrittyBrick
  • 81,981
  • 20
  • 135
  • 205
  • And also related [Why is whitespace sometimes needed around metacharacters?](http://stackoverflow.com/q/21186724/1983854) with a funny story around :) – fedorqui Aug 08 '14 at 11:24