I've seen a pro sysadmin deal with the loss of all device files on a linux box by just uuencoding them in one terminal on a working machine and then pasting them into the other terminal and piping them back from standard in. Pretty impressive and not even breaking sweat.
I've been using Linux for 8 hours a day for 13 years and never done this. I use GNU's alternate syntax, which is easier:
rm [object] [options]
Eg,
rm /var/tmp/foo -rf
If you hit enter too early, nothing bad happens. Obviously doesn't work on HPUX, Solaris, DGUX or Ultrix, but if you're using those you have other issues.
I always put a comment at the beginning of nontrivial commands, so accidentally hitting enter prematurely doesn't do anything and so I can check it once it's written out before removing the comment and hitting enter.
Maybe it's me being an old weirdy beardy, but what's with all the oooooold hacker folklore on HN recently? I keep expecting to see someone post 'more magic'. Can we not just post a link to the Jargon File and be done with it?
I once typed rm -rf /bin instead of rm -rf bin on AIX. I Ctrl-C'ed quickly but all commands in /bin beginning with A and B and some C had vanished... The big problem is that the huge majority of AIX commands rely on awk, which had vanished together with all A's...
Eventually had to reinstall system from tape.
Had a similar thing happen the first time I used a GUI to admin a Linux box. I had a fresh install and was doing my usual post-install hardening (removing unneeded packages & users).
The GUI had a checkbox for removing the users home directory. Things were going good until I removed the user 'mail' whose home directory was '/'.
Not a very scalable solution, but if there is a file named -X where X is any option to rm, * will expand to catch it, and if illegal, rm will exit without doing anything. Someone taught me that in college back in the day (sequent/dynix).
With virtualized machines, you can make a hot backup every day, so if something egregious like this happens on a virtualized machine you can (at most) lose a day's work.