Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I admit it is a homework but I am lost in explaining the following command line:

WARNING: This is a so called FORK BOMB! This command line can and will crash your pc by consuming all RAM and CPU (trust me, I tried it...)

:(){ :|:& };:

As I know that I should do it alone here is what I have so far (searching for these chars is very discouraging).

  1. The pipe enables to concatenate some commands together so that the first output is used by the second as input.
  2. The & is to run a command in the background (basically used to start something from a shell which shouldn't be blocked by the command)

I guess that : is to fork? But here I am totally lost! I am willing to learn, so maybe someone have a good resource where I can read about that?

share|improve this question
    
@kkp: isn't a situation where your system is not responding a similar to a crash? The solution to fix it is the same: hard reset the system –  WarrenFaith Jun 8 '11 at 18:01
    
Yeah..you are right. –  samarasa Jun 8 '11 at 18:03
    
FORKBOOOOOMB :D –  zookalicious Jun 8 '11 at 22:54

1 Answer 1

up vote 14 down vote accepted
:()      # define ':' -- whenever we say ':', do this:
{        # beginning of what to do when we say ':'
    :    # load another copy of the ':' function into memory...
    |    # ...and pipe its output to...
    :    # ...another copy of ':' function, which has to be loaded into memory
         # (therefore, ':|:' simply gets two copies of ':' loaded whenever ':' is called)
    &    # disown the functions -- if the first ':' is killed,
         #     all of the functions that it has started should NOT be auto-killed
}        # end of what to do when we say ':'
;        # Having defined ':', we should now...
:        # ...call ':', initiating a chain-reaction: each ':' will start two more.

Source: Forkbombs on Wikipedia

share|improve this answer
    
thanks... it sounds pretty evil! Didn't know that you can define a method this way. very interesting –  WarrenFaith Jun 8 '11 at 18:02
    
could you tell me how you found that wikipedia article? I tried to but didn't succeed... –  WarrenFaith Jun 8 '11 at 18:14
    
I already knew what to search for ;) –  Egil Jun 8 '11 at 18:17
2  
Ok, so you are an evil bad hacker :) thanks anyway! helped me a lot –  WarrenFaith Jun 8 '11 at 18:18
    
Most of us who have browsed the Ubuntu forums have been warned many times about running forkbombs or sudo rm rf you know the rest etc... Dunno if that's where Egil got it from though :P –  zookalicious Jun 8 '11 at 22:55

Your Answer

 
discard

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.