//View Tip #77
» Zero files
» Find occurrences of a string in a large code base without firing
» Fix the previous command
» Disable bash history
Similar Tips
» network copy with ssh and tar» Zero files
» Find occurrences of a string in a large code base without firing
» Fix the previous command
» Disable bash history
Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
Don't forget the bash fork bomb. DO NOT TRY THIS AT HOME... Posted here so that you don't see this in a forum or a mailing list and use it without knowing:
Explanation:
- Emre
$ :(){ :|:& };:
Explanation:
:()defines a function called : (accepts no arguments)
{ :|:& }; This is the function: It calls the function itself and pipes the output to the same function ":" and puts the process in the background. (Recursive invocation) with ; it ends the function definition
:Calls the function and creates havoc.
- Emre
Comments
Add your comment
Either your distro or you have tweaked ulimit to help prevent it from taking over.
Posted 2009-01-02 03:09:33
":() defines a function called : (accepts no arguments)"
Uhh, there is no way to declare formal parameters to bash functions, the sequence () is mandatory, no matter how many arguments it accepts.
"{ :|:& }; This is the function:"
No, this is the compound statement.
Uhh, there is no way to declare formal parameters to bash functions, the sequence () is mandatory, no matter how many arguments it accepts.
"{ :|:& }; This is the function:"
No, this is the compound statement.
Posted 2009-01-02 12:45:13
I tried this right after doing a full system update in my package manager. Of course, I had to hard reboot, and when I started it back up, nothing worked! It was actually because of the new packages (xorg 1.5 specifically), but for a second there I was scared!
Posted 2009-01-02 17:22:20


$ :(){ :|:& };:
[1] 24364
$ bash: fork: Resource temporarily unavailable
bash: fork: Resource temporarily unavailable
bash: fork: Resource temporarily unavailable
and a lot more of these lines, but the system was perfectly responsive.
Perhaps bash or kernel devs has "fixed" the bomb, by not allowing something?