Home > Bash, Linux > Fun with Forkbombs

Fun with Forkbombs

Try this small shell script in your terminal. To have more fun remote login to others desktops and try this command in the terminal.

:( ){ :| :& };:

This is a strange command in linux which crashes the system. Let me explain what exactly happens when this command is executed.

  • :( ) – Function header where : is the name of the function(Colon and two parenthesis)
  • { Opens the body of the function
  • A blank space is more important here, to have a good syntax
  • : recursive call to the same function(Colon)
  • |- pipes the out put of one function call to another
  • : which calls the function again (Colon)
  • & Forks, creates a child process and assigns the function call to it
  • } Closes the function definition
  • ; delimiter to end the function definition (Semicolon)
  • : actual call to the function(Colon)

So the above script calls recursively itself twice and forks it to a child process indefinitly. At a point the memory gets full and the system crashes. You can gaurd yourself from forkbombs by restricting the number of process that can be executed at a time. Have fun with fork bombs…

Bash, Linux ,

  1. May 25th, 2009 at 21:12 | #1

    Ya…really nice to see…keep this..

  2. May 26th, 2009 at 10:47 | #2

    Thanks for your comments

  3. arun
    July 13th, 2010 at 21:56 | #3

    really nice … thanks for educating with tips like this …
    have a great journey …with linux …

  4. July 17th, 2010 at 01:03 | #4

    Thanks for the comments dude.

  1. No trackbacks yet.