How to Avoid Accidentally Deleting Files in Terminal

I’ll never forget the time when I was working as a network engineer, and a coworker brought an entire college campus grinding to a halt with a simple misplaced dot.

The mistake my colleague made, was to type:

rm -rf /*

Instead of:

rm -rf ./*

The second command recursively removes all files from the current directory and all child directories. The first removes all files from the _root _directory and all child directories. The root directory on a Unix system is the top-level directories that contains the entire filesystem.

To make matters worse, my colleague was logged in as the root user, which has full admin rights. rm does not prompt for confirmation before deleting files.

So, with 10 simple keystrokes, he accidentally wiped an entire live server. Suffice to say the network manager wasn’t amused!

#unix #programming #software-development #linux #terminal

How to Avoid Accidentally Deleting Files in Terminal