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?
1 Answers
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
- What does this cryptic Bash command mean?
- Why this command crashes Linux
- What this command :(){ :|: & };: does?
Other related questions
- 85,717