'rm -rf *' for Dummies

Everyone who has worked a bit with Linux/Unix/OSX knows that the command 'rm -rf *' is kinda destructive (understatement). Compare it with the old 'deltree.exe' command in MS-DOS. The latter explains it without saying too much about it.

Anyway, yesterday I ran into an annoyance of OSX (and it wasn't the first time I ran into it). Every once in a while when I mount a smb share on my MacBook Pro nothing happens. When I try to connect again I get a message that I'm already connected to that share :?: :?: , but there's no visible indication in the Finder of this.
The way to see the shortcut to the share (for me at least) is to relaunch Finder (Force Quit). But this is highly annoying.

Yesterday I decided to take a look under the hood, and started terminal and opened the Volumes directory. This contained over 30 sub directories, and they all had names similar to the smb shares (ftp, ftp-1, ftp-2, web, web-1, etc). the directories were empty (the +10 I checked anyway), so I wanted to delete al those directories in the hope that my annoying messages about being connected would be gone.

First I entered every directory and removed the .DS_STORE file by hand and after that I removed the directory with rmdir. This would take more time than I wanted to spend, so I needed something quicker, and what's quicker than the rm command with all the appropriate switches??
I made sure that I wasn't executing the command from the root of the drive (he, I'm not that stupid). So after I executed the command I heard something weird. I heard the hard disks in my server go crazy.....


AAAARRRRGGGGGHHHHH
Aaaaaarrrggghhhh


Somehow there still was a share mounted, and the rm command was recursively deleting ALL content on the share. By the time I realized this (about 5 to 10 seconds) my 300GB drive was 90% empty instead of 95% full.Thankfully I had some excellent undelete tools on my server so I was able to recover the content over the network to my PC, and after that I could copy them back to my share.
Posted on August 27, 2007 and filed under Annoying, Apple, Personal.