Home > Uncategorized > pipe dream

pipe dream

So my server has been randomly rebooting, and I suspect corrupted data to be the cause of it. I can reliably force the reboot if I do certain tasks, all of which point to one partition on the main drive. I’ve been backing things up to do a fresh install of the OS. There are mistakes on this box several years old from when I was first learning Unix, and it’s about time I started fresh.

I had finished backing up the last of the videos and stuff in my /pub directory, and was ready to wipe the originals. then all I’d have to do is transfer the massive archive file to my other machine when I got home and I’d be done. I decided to go ahead and clean up the directory first. I forgot 2 terms in the command I used to clean the directory, and ended up deleting half the server. any other day I would have been super-pissed, but I already got most of the important info off the machine. the video files, although numerous, can be replaced.

My intention was to have the string list directory contents, filter out everything but subfolders, then delete those subfolders. I typed the following command from /pub:


ls -al | egrep ^d | xargs rm -r

Anyone *nix savvy knows this captured the “../” (“parent folder”) directory, sending the remove command to the root directory and telling it to recursively remove everyhing there (that being “every file on the machine”). if I hadn’t hit ctrl-c immediately, it would have completely wiped the drive as if I had typed “rm -r /”. this is the *nix equivalent of “erase c:\*.*”, except in linux it will actually remove everything… programs are loaded into memory at runtime, allowing running files to be modified (or removed). I was only missing a few terms. it should have been


ls -al | egrep ^d | awk '{print $9}' | egrep ^[aA-zZ] | xargs rm -r

For the want of a horseshoe…

I think this is a pretty obvious omen that I need to be better about regular backups.

also, if you’ve gotten this far you’re either a major geek or a closet geek.

Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.