what does this command does in bash: ,_,( ){ ,_,| ,_,&};,_,

陌路散爱 提交于 2019-12-10 03:39:41

问题


,_,( ){ ,_,| ,_,&};,_,

I am not sure what it means...

Looks like a bash command but it might be s bash shell directive or something would appreciate if someone can help understand this. It killed my bash when I ran it.


回答1:


It's a fork bomb; it will spawn a (potentially) infinite number of processes, until your system runs out of resources (and usually becomes inoperable).

It defines the function named ,_,, which runs itself (recursion), and piping the output to itself. The last ,_, is needed to start off the thing.

Formatted, and with ,_, replaced by fun, it looks like:

fun() {
   fun | fun &
};
fun

Every invocation of fun will spawn 2 more invocations of fun. The & starts the processes in the background (rate of process increase is exponential).

It's a variant of the better known :() { :|: & };:

There are ways to prevent your system from crashing, though; for example in Linux you can edit /etc/security/limit.conf & set the maximum number of processes for a user. Other systems have other (usually similar) methods.

Running a fork bomb and crashing your system seems to be something of a rite of passage for UNIX users; it teaches you:

  1. The importance of imposing resource limits of processes;
  2. that copying & executing commands you do not understand from untrusted sources (eg. the internet) is not a good idea


来源:https://stackoverflow.com/questions/27197785/what-does-this-command-does-in-bash

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!