Yes `yes no`
blog.michaeltang.me
blog.michaeltang.me
Instead, all you're seeing is bash thrashing as it tries desperately to capture all the output of `yes no` in-memory.
I expect you'd see the exact same behavior with echo `yes no`.
Now if you really want to screw over your machine, the classic bash fork bomb is
:(){ :|:& };: dd if=/dev/random of=/dev/sda
Depending on how long does it run, you end up with a more or less screwed computer. It's funny to see how does the machine fall over when you invoke a simple 'cd' command after this.(The server was part of a MogileFS cluster so there were multiple copies of the data online. There was no data loss, not even any downtime. Still, it was scary as hell, and I spent all Saturday in the data center restoring the box.)
$ foo < bar # runs command `foo`, reading from `bar` on stdin
$ foo > bar # runs command `foo`, writing stdout to `bar`
Writing `>` instead of `<` has resulted in many a blowup at 3 AM ssh remotehost.example.com mysqldump -udbuser proddatabase | mysql -uroot testdatabase
(n.b. the mysqldump options that may lock your production tables during the dump.) rm * -i
The system response was "-i not found" or something like that. rm bob*
has completely different behavior from rm bob *
The above line of code successfully fixed a bug I'd been trying to find for weeks in source code in the same directory. When I rewrote it from scratch, the bug was gone. rm /tmp/*
zsh: sure you want to delete all the files in /tmp [yn]?I avert the problem by having rm run interactively by default:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
http://aniggler.tumblr.com/post/44530262158/the-first-thing-... while :
do
clear > /dev/tty
sleep 5
done(for ref, we had to do very naughty things to SunOS 4 to add it to /etc/shells)
It picks a random device on your system -- ram, video, bios, etc -- and writes a random number of random bytes into it and then sleeps for a random amount of time.
Last one standing lives.
/dev/sda1 is the first partition on that drive, /dev/sda2 the second, and so on. /dev/sdb is the next hard drive, /dev/sdc the next after that; beyond /dev/sdz, the naming scheme is apparently dependent on the hardware driver in use: Going from /dev/sdz to /dev/sdaa is what happens in the default SATA and SCSI drives, up to /dev/sdzzz, at which point you apparently run into problems. [1]
http://rwmj.wordpress.com/2011/01/09/how-are-linux-drives-na...
[1] http://kerneltrap.org/mailarchive/linux-scsi/2010/9/20/68866...
Actually, you're wrong. At least on a mac (IIRC) it caps the process number so fork bombs just fill the console with errors. I'm sure you can get around it but that kind of defeats its simplicity.
EDIT: I mean, don't get me wrong, it still really bogs your computer down, but you can still kill the parent bash process in a few seconds.
Can someone explain how it works?
zooey:~ duane$ ulimit -u
709 s=`foo` CORES=4
for i in {1..$CORES}; do yes > /dev/null &; doneThen i tried again, in a subshell, and let it run...
[user@machine] ~ % zsh
[user@machine] ~ % yes `yes no`
zsh: fatal error: out of heap memory
[user@machine] ~ %
[user@machine] ~ % bash
user@machine:~$ yes `yes no`
bash: xrealloc: ../bash/subst.c:5184: cannot allocate 18446744071562067968 bytes (4297060352 bytes allocated)The 4GB limit is maximum memory that can be allocated to a process (this is configurable) http://en.wikipedia.org/wiki/OOM_Killer
It doesn't do any harm, promise.
while [[ 1 ]]; do c=(╱ ╲);printf ${c[RANDOM%2]}; done
It's a cheesy maze generator. tr '\000-\377' '[/*128]\\' </dev/urandomUnless you're running tmux, obviously...
sudo rm -rf /
That is, if it would actually work: modern rm implementations have a special case for /. Read the manpage and/or try this instead:
rm -rf --no-preserve-root /
http://www.gnu.org/prep/standards/html_node/Semantics.html
(as others have noted, the program actually doing something here is bash: it attempts to dynamically allocate as much memory as it can to store the output of 'yes no'. Hopefully the author discovers ulimit.)
An old favorite of mine was the elegant: `yes > no` [1]
[1] I'm fairly certain I made this up... though it's obviously trivially easy to "discover" on your own.
Every so often I'd come to my machine and just have a blinking cursor on a blank screen and have to figure out how to get back to a working machine.
Don't do this unless you want a bad day: :)
`printf "\ fr- mr odus"|rev` sudo rm -rf \
...doesn't do anything.rev(1) doesn't reverse your slashes. :D
EDIT: Got the output by running bash in bash:
bash: xrealloc: ../bash/subst.c:5184: cannot allocate 18446744071562067968 bytes (4296822784 bytes allocated)
So now I'm wondering why 18446744071562067968 bytes is the next logical step after 4GB.
Bash is full of bugs like this; e.g. on a 64-bit system try doing echo $[263/-1].
$ bash --version
GNU bash, version 4.2.37(1)-release (x86_64-pc-linux-gnu)
...
$ echo $[263/-1]
-263
What is it "supposed" (failure case) to do? $ echo $[2**63/-1]
Floating point exception
Bash crashes out entirely because it doesn't check the operands are safe. See also http://kqueue.org/blog/2012/12/31/idiv-dos/2^64 = 18446744073709551616
cat /usr/share/dict/words | perl -mList::Utilhuffle -e 'print shuffle(<STDIN>);' | head -n 5 | say -r 150
yes 'yes yes&' | shFinding all of the programs that are isomorphic to this one when given certain input, now... that's the problem.
Note that "yes, and" is very different from "yes, but."
Source: _Improv Wisdom_.