What is fork bomb?
In order to protect your Linux system from certain virus or malware attack, it is essential to know how this virus is generated and how it affects the system. Fork Bomb also known as Rabbit Virus is used by hackers to stop system working by creating infinite chain of tasks. These tasks start running in the background and keep being generated until all system resources are exhausted and the system hangs, in other words, it can be called a Denial of Service (DoS) attack.
Formation of the fork bomb
The formation of Fork Bomb is then mentioned below:
To understand Fork Bomb creation and how it works, consider the following syntax:
- :() is used to declare a function and is represented by :function
- is the body of the function that contains commands to crash the system
- :|: starts the replication of the function, here first : the function is called and then | replicates the function:
- & Moves the entire function to the background to avoid killing child processes
- ; disconnects the child processes and terminates the statement
- : Runs the created function
How to prevent and repair fork bombs
The possible solution to prevent Fork Bomb is to limit the number of processes one can run on a Linux system and see what limits the use of programs by default:
Next, add the limit of programs using the following syntax:
For example, if you want to limit the number of processes to 10000, use:
If you want to limit the number of processes for a specific user, open the configuration file with:
Next add the number of background programs for each user using the following syntax:
For example if I want to add a limit of 500 for a specific user then:
Next, save the file and reboot the system to apply the changes:
This is how to protect Liunx system from Denial of Service (DoS) attack, in case your Linux system is attacked by Fork Bomb, just reboot it to get it back to normal state.
Fork Bomb is a denial of service (DOS) attack that creates a chain of repetitive tasks to consume all of the system’s resources, and keeps generating tasks until the system crashes. The best way to prevent such malware attacks is to limit the number of background processes as this will stop generation of repetitive tasks thus preventing system crash.