“\rm -fr *”: F***K!! Not me…

Damn it! I mistakenly removed all the files from /usr/local/. I usually do not use “\rm -fr *”, but it happened so quick by the time I could hit Control-C it was too late! I knew I was in /usr/local, but I was recalling a command and mistakenly hit enter when I reached “\rm -fr *” in /usr/local.

Lucky for me I placed all important files in an subversion repository on another server. Thank God I committed the most recent changes for the Nagios configuration. And, my home dir is on nfs, so there! But, I still have to reinstall my OS! This I can deal with. In a day or two I should be where I left off.

How could I have prevented “\rm -fr *” from doing anything useful?

Easy: Touch “-i” in an important folder

In that case I would have been prompted! After the reinstall I issued:

# touch /./\-i
# touch /root/./\-i
# touch /usr/./\-i
# touch /usr/local/./\-i
# touch /usr/local/./\-i
# touch /etc/./\-i
# touch /var/./\-i

Just in case.

Extra Paranoid: Touch “–__–” instead in an important folder

# touch /./\-\-\_\_\-\-
# touch /root/./\-\-\_\_\-\-
# touch /etc/./\-\-\_\_\-\-
# touch /usr/./\-\-\_\_\-\-
# touch /usr/local/./\-\-\_\_\-\-
# touch /usr/local/etc/./\-\-\_\_\-\-
# touch /var/./\-\-\_\_\-\-

An “ls /usr” shows:

–__– .snap compat games lib libexec obj sbin src
-i bin doc include libdata local ports share

The above will not even prompt you!, but “\rm -fr *” will not execute — at all. To show you that I am not lying I execute the following in /usr/local/

# cd /usr/local
# ls
–__– bin include lib libexec sbin www
-i etc info libdata man share
# \rm -fr *
rm: illegal option — –
usage: rm [-f | -i] [-dIPRrvW] file …
unlink file
# ls
–__– bin include lib libexec sbin www
-i etc info libdata man share

I feel better now:)

Advertisements
This entry was posted in *Nix. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s