Last week I talked about how the producers of Toy Story 2 nearly lost a year’s work by accidentally deleting files. Unplugging the machine is about the worst thing you can do after entering an inadvertent
rm *. There are, however, things to do even if you’ve deleted the only copy in the world of a file.
First, heed the advice in The Hitchhiker’s Guide: Don’t panic! In fact, don’t do anything until you have a clear idea of what to do. Your file is only mostly dead. The bits are most likely still there, but there’s no longer a file directory entry claiming and protecting them, so they’re fair game for any application to devour them. Any useless action could make exactly that happen.
The right utility can put those bits back into a file, but it has to be the first one to get at them. If you already have it right at hand, that’s the best case. If not, download it on some other computer and put it onto a USB stick or CD-ROM. Don’t let anyone touch the afflicted computer while you’re getting ready.
A popular utility for this purpose is TestDisk. It’s available for most modern operating systems and runs as a command line utility. Here’s a case study in its use, along with the companion utility PhotoRec. Command line programs make the least use of system resources and so aren’t as likely to make something get written out to the disk. The downside is that they aren’t as user-friendly. I’ve just downloaded TestDisk and found that it assumes you know a few things about disks and partitioning schemes. It can be a little intimidating for a user, especially one whose job is on the line if those files disappear for good. If it’s recovering files on a device using the old FAT16 file system, it may show you short uppercase file names. It doesn’t work 100% of the time. I created a short text file called lazarus.txt and deleted it, then used TestDisk to recover it. It found something called _AZARUS.TXT, which I copied only to find just a decayed pile of mouldering bits.
There’s some discussion here of the ultimate doomsday scenario, typing in
rm -rf /*. Last time I said you should think three times before doing
rm *. If you’re ever tempted to type in
rm -rf /*, seek immediate psychiatric counseling. The article includes suggestions to use TestDisk and PhotoRec, but we never learn how much if anything the unfortunate soul could salvage.
Becoming an expert with these utilities clearly takes a bit of work, but if you’ve practiced a bit you might still be able to get yourself out of a jam. If you’re so inclined, you might even become an expert on them and be a consultant or local hero. They can call you Miracle Macs.