Monday, April 29, 2024
397
rated 0 times [  397] [ 0]  / answers: 1 / hits: 304714  / 2 Years ago, sun, october 16, 2022, 9:15:45

DANGER!


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?



:(){ :|: & };:



More From » command-line

 Answers
3

This is called a fork bomb.


:() means you are defining a function called :


{:|: &} is the : function's body. It calls the function : recursively and sends (pipes) its output to another call of :. And & means the created process must run in the background.


The ; is a command separator.


The final : 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.


[#37098] Monday, October 17, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eving

Total Points: 162
Total Questions: 102
Total Answers: 112

Location: Trinidad and Tobago
Member since Thu, Dec 1, 2022
1 Year ago
;