## : () { : | : & } ; : A cool hack for Linux geeks

Have a close look at this one-liner that can be executed. Beware! Don't execute it on a box without understanding the consequences completely.

: () { : | : & } ; :
Do you find this thing too geeky? We'll simplify it. It is deliberately obfuscated.

The : is a function name. It could very well have been f.

Let us replace : with f and see what it looks like.

f () { f | f & } ; f


Now it looks familiar. We have two commands separated by a semi-colon:

f()
{
f | f&
}

f

So with that one liner command, we create a function f and then execute it.

This function calls itself recursively. Soon, the box is full of many instances of this process.

It can be seen that the function is called twice. So, we see an exponential growth in the number of processes. The & runs them in the background.

This one-liner command is actually a fork bomb. On execution, very soon the system is full of thousands of that function thereby depleting CPU cycles, memory and process table. The box is rendered useless. So you should try it on your box only.

#### Tejas Dinkar said:

Lol, who knew that : was a valid function name?

It isn't a valid variable name in BASH though :p. I think it should be a valid fork bomb even withouth the pipe.

#### Susam Pal said:

Yes : is a valid function name though it isn't a valid variable name.

There are a few more too:

susam@nifty:~$-() { echo hello, world; } susam@nifty:~$ -
hello, world
susam@nifty:~$_() { echo hello, world; } susam@nifty:~$ _
hello, world
susam@nifty:~$,() { echo hello, world; } susam@nifty:~$ ,
hello, world
susam@nifty:~$~() { echo hello, world; } susam@nifty:~$ \~
hello, world


The pipe is there to make the growth in the number of processes exponential.