Linux Fork Bomb


Fork bomb is a form of denial-of-service attack against a computer system. Fork bombs typically do not spread as worms or viruses, but it works by creating a large number of processes very quickly in order to saturate the available space in the list of processes kept by the operating system. If the process table becomes saturated, no new programs can start

Syntax : [root@server ~]# :(){ :|: & };:

:( )   # define a function ‘:’ — so whenever we say ‘:’, execute this function

{      # 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.

Ref : http://www.switchroot.com/how-to-create-a-linux-fork-bomb

How to limit CPU usage for certain process in linux


Scenario: There is a challenge for us to limit the cpu usage for certain process where the real live application usage will utilize more cpu usage.

Solution:

cpulimit is the command where you can limit the cpu usage for unnecessary process.

eg: cpulimit –pid <PID of process> –limit <CPU usage limit in percentage>

Syntax : [root@server ~]# cpulimit –pid 2960 –limit 70

For more info : #man cpulimit