Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is this piece of code doing? :(){:|:&};:

Tags:

bash

Sorry for asking such a general question but this has been bugging me for days.

A friend gave me this piece of code (?) and wont tell me what it does, or even if it is C or bash or anything else.

From the look of it, it looks like C to me. Although I dont get why there are : on the sides.

:(){:|:&};:

Any clues will be appreciated.

like image 641
Dimme Avatar asked Dec 05 '11 02:12

Dimme


People also ask

What is a piece of code?

In this article, we define a piece of code by using the code Element. It is used to define the piece of computer code. During the creation of web pages, sometimes there is a need to display computer programming code.

What is this in code?

this, self, and Me are keywords used in some computer programming languages to refer to the object, class, or other entity of which the currently running code is a part. The entity referred to by these keywords thus depends on the execution context (such as which object is having its method called).

What is a purpose of a code?

Coding creates a set of instructions for computers to follow. These instructions determine what actions a computer can and cannot take. Coding allows programmers to build programs, such as websites and apps. Computer programmers can also tell computers how to process data in better, faster ways.


2 Answers

This is bash shell script, not C.

It's a fork bomb.

Wikipedia explains it:

:()      # 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.
like image 169
SLaks Avatar answered Oct 18 '22 15:10

SLaks


This is a fork bomb and I would not run that on your system. It will cause a bunch of processes to spawn and ultimately slow down or crash your system.

like image 33
in70x Avatar answered Oct 18 '22 15:10

in70x