News for hackers. Stuff that matters.
Re:Yes `yes no` by gjulianm on Wednesday March 13, 2013 @06:23PM (#5371528)
I've always preferred this tougher command to screw VMs I was going to delete.

    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.
Re:Yes `yes no` by RyanGWU82 on Wednesday March 13, 2013 @07:07PM (#5371699)
It's not so funny when you do this accidentally, on a 2 TB disk full of user data, on a live production server, at 2AM on a Friday night...

(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.)

Re:Yes `yes no` by xyos on Wednesday March 13, 2013 @07:10PM (#5371710)
how did you end up doing this accidentally?
Re:Yes `yes no` by niggler on Wednesday March 13, 2013 @07:23PM (#5371788)
I've seen stranger: a redirect gone the wrong way

    $ 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
Re:Yes `yes no` by opcode on Wednesday March 13, 2013 @10:06PM (#5372654)
I did this with a DELETE SQL WHERE clause, trying to isolate a set of records, instead selecting all records, in an effort to test a production installation, at 3am (YES) and had to buy 3 db admins lunch the following day because they came in to restore multiple customer tables. The DELETE's were triggered across numerous tables and platforms (AS400 and SQL Server). The walk of shame to tell my director was not my most shining moment. I'd like to go back in time and slap myself just moments before. Running commands on live production data. Silly programmer.
Re:Yes `yes no` by sneak on Thursday March 14, 2013 @02:48AM (#5373457)
At least with MySQL's tools, thanks to ssh's happiness to work as a pipe, it's very easy to clone a database locally for fucking about when you're trying to do something like this:

  ssh remotehost.example.com mysqldump -udbuser proddatabase | mysql -uroot testdatabase
(n.b. the mysqldump options that may lock your production tables during the dump.)
Re:Yes `yes no` by huherto on Wednesday March 13, 2013 @07:55PM (#5372021)
My friend did this...

  rm * -i 
The system response was "-i not found" or something like that.
Re:Yes `yes no` by ISL on Wednesday March 13, 2013 @10:04PM (#5372646)
I once discovered that apparently

  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.
Re:Yes `yes no` by michaelmior on Thursday March 14, 2013 @12:12AM (#5373046)
This is certainly different. " bob* " refers to all files that start with "bob". " bob * " refers to a file named bob as well as all files.
Re:Yes `yes no` by sneak on Thursday March 14, 2013 @02:45AM (#5373447)
Thank you, Donny.
Re:Yes `yes no` by niggler on Wednesday March 13, 2013 @11:01PM (#5372825)
rm -i is your friend
Re:Yes `yes no` by dfrey on Thursday March 14, 2013 @02:12PM (#5376664)
I find rm -i to be unusable because it is so annoying when you are deleting more than a couple files. It would be nice if rm -I (notice the capital) would first determine all of the files to remove, print them out and then ask if you want to delete all of those files. Instead it just says "rm: remove all arguments?" which is clearly much less annoying than having to type y for every file, but it is also mostly useless.
Re:Yes `yes no` by skateinmars on Thursday March 14, 2013 @06:41PM (#5378104)
Zsh almost does this when using rm * :

  rm /tmp/*
  zsh: sure you want to delete all the files in /tmp [yn]?
Re:Yes `yes no` by niggler on Wednesday March 13, 2013 @11:01PM (#5372823)
protip: always put -i first.

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-...
Re:Yes `yes no` by mietek on Thursday March 14, 2013 @01:34AM (#5373254)
Until one day, lulled into a false sense of security, you find yourself on a system without these aliases…
Re:Yes `yes no` by hakaaaaak on Thursday March 14, 2013 @01:35AM (#5373257)
I usually don't alias the command itself; that's bad form. It limits what you can do and screws you when you are using an environment without your alias when you forget it. Live and learn.
Re:Yes `yes no` by RyanGWU82 on Sunday March 17, 2013 @09:22PM (#5391857)
Exactly -- I was benchmarking a disk that was having a performance problem. and I did something like "dd if=/dev/zero of=/dev/sda" instead of "of=/testfile".
Re:Yes `yes no` by Dylan16807 on Wednesday March 13, 2013 @08:23PM (#5372217)
That doesn't sound so bad. /dev/random is slow, you have plenty of time to catch it. It probably won't even reach the first partition. urandom on the other hand...
Re:Yes `yes no` by eru on Thursday March 14, 2013 @04:18AM (#5373762)
Depends on your system. In BSD /dev/random is /dev/urandom.
Re:Yes `yes no` by RyanGWU82 on Sunday March 17, 2013 @09:20PM (#5391854)
/dev/zero is plenty fast... :-/
Re:Yes `yes no` by huherto on Wednesday March 13, 2013 @07:03PM (#5371684)
Aahhh. In the old days, we used this command just to mess with your workmates.

  while :
  do
     clear > /dev/tty
     sleep 5
  done
Re:Yes `yes no` by hp50g on Thursday March 14, 2013 @08:26AM (#5374476)
We wrote our own shell when I was at university (which was completely offensive, not at all obedient and generally no help whatsoever) and chsh'ed them if they left a terminal open :)

(for ref, we had to do very naughty things to SunOS 4 to add it to /etc/shells)

Re:Yes `yes no` by jimfl on Thursday March 14, 2013 @10:09AM (#5375007)
/usr/games/worms is the best shell ever.
Re:Yes `yes no` by hp50g on Friday March 15, 2013 @05:01AM (#5379729)
Never thought of that - great suggestion :)
Re:Yes `yes no` by srl on Wednesday March 13, 2013 @06:27PM (#5371549)
Back when `/dev/mem` was a thing in default kernels (now you need a special config, or a module), I enjoyed `cat /dev/urandom > /dev/mem`. That would usually bork things pretty quickly, so then I would set random offsets with `dd`. Fun times.
Re:Yes `yes no` by mikeash on Wednesday March 13, 2013 @06:56PM (#5371660)
Re:Yes `yes no` by zx2c4 on Wednesday March 13, 2013 @07:01PM (#5371678)
Or try this -- http://git.zx2c4.com/memory-hemlock/tree/slow-death.c

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.

Re:Yes `yes no` by eridius on Wednesday March 13, 2013 @06:53PM (#5371649)
What's /dev/sda?
Re:Yes `yes no` by gjulianm on Wednesday March 13, 2013 @06:56PM (#5371658)
On Linux, the hard disk. This command, dd, copies data in bulk from /dev/random (a special device on *nix that outputs random bytes) to /dev/sda (your hard disk). That means it starts to overwrite your disk with trash, rendering the system unusable.
Re:Yes `yes no` by eridius on Wednesday March 13, 2013 @07:06PM (#5371695)
I know what `dd` is. I just don't use Linux, so I'm not particularly familiar with the Linux-specific /dev entries. Thanks though.
Re:Yes `yes no` by aroman on Wednesday March 13, 2013 @06:56PM (#5371661)
Most probably the storage device which is your HD.
Re:Yes `yes no` by aidos on Wednesday March 13, 2013 @06:58PM (#5371670)
Probably your main drive.
Re:Yes `yes no` by derleth on Wednesday March 13, 2013 @07:15PM (#5371739)
The device file applications can use to access the first hard drive on most Linux systems. It provides raw access without filesystems or partitions.

/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...