Never Type This As Root

I was working on a shell script this morning to make my life easier on some trivial task. The last few lines looked a little like this.

somedir=/mnt/tmp
mv $somedir/*.txt ~
rm -rf $somdir/*

Obviously I meant to remove all the files in the directory, however a typo in the variable name led to the deletion of /. I caught it before it got to the home folder, but bin and dev were gone resulting in a broken system that needed to be reinstalled.

Never delete * as root unless you are sure you know what you are doing….

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.