4 ms·
`yes` (with the backticks) is my favorite "bring the system to its knees right now" shell command.
by jvolkman 9y ago
`yes` (with the backticks) is my favorite "bring the system to its knees right now" shell command.
- AstralStorm 9y agoDoes not do that on modern Linux or especially -ck patch.
- jvolkman 9y agoGood to know. I think the last time I tried it was on a rhel5 or rhel6 variant. However, as avip found out below, it does still render OS X useless within less than a minute (at least on my 2015 MBP).
- ZenoArrow 9y agoWhat does `yes` try to do?
- statictype 9y agoI'm guessing it tries to read the output and return it. Since yes doesn't actually terminate it's going to generate a massive temporary variable to store it's continuous output.
- aexaey 9y agoThis will attempt to open a child shell process with whatever output of "yes" is, interpreted as shell script. But before that, parent shell has to buffer until EOF. With "yes" output being unbound, this means unbound buffering / memory growth. That is, until OOM killer take notice and shut it down. Whole thing will probably take few seconds to a minute (depending on how much free RAM there is vs. how fast it is), peg a single CPU core in the process, and will recover cleanly (except for shell in question being terminated). ...unless system in question has single CPU and large+slow swap. Then yes, bring-it-to-its-knees.
- marcosdumay 9y agoIt may also push everything in memory to swap in the process, what is the real speed killer.
- AstralStorm 9y agoMake sure to have a sane memory limit set in PAM and switch vm.swappiness to lower value than 60.
- AstralStorm 9y agoSingle CPU is fine nowadays. It will be slowish if you ran it with no nice or priority. RAM can be tweaked by preventing Linux heuristic overcommit via sysctl vm.overcommit_memory=2. (0 is only recommended if you do not run broken applications. It so happens that many JS and Java VMs are broken on memory pressure.)
- avip 9y agoWell thanks for killing my mac. People are trying to work here you know.
- danielsamuels 9y agoYou took a command from a comment which said they use it to "bring their system to its knees", ran it, and then complained?
- avip 9y agoI thought that's what internet is for.
- garaetjjte 9y agoHow? Only eats 2GiB and crashes bash with bash: xrealloc: cannot allocate 18446744071562067968 bytes