Bash fork() bomb

Today, I stumbled onto the following nasty bit of shell code in SECURITY Limit User Processes over on the Gentoo Wiki. No, I haven’t switched to Gentoo.

:(){ :|:& };:

Warning, this will cause your shell to create processes as fast as it can; most likely grinding your computer to a halt if you don’t have the appropriate limits set.

After spending some time trying to figure out what this command was doing assuming the colon was functioning as a no-op, I did a quick Google search and found this nice explanation of what it actually does. So, today I learned that Bash allows functions to be defined which override built-in commands.

2 thoughts on “Bash fork() bomb”

  1. Well, I appreciate your blog. I have spent the last few hours learning & playing – mostly playing with Gentoo..:-)

Leave a Reply

Your email address will not be published. Required fields are marked *