Safety tactics with `rm`
Here are my catastrophy avoiding tactics for the
rm -iin my
alias rm="rm -i" # Make rm interactive by default.
Whenever I use the
rfcommand, I make sure never to pass the
*argument. Always put something with
*. This expliciteness has the double benefit of preventing the mistake of being in the wrong directory when issuing the command, while also keeping your command history free of dangerously versatile and destructive commands.
~ $ pwd /home/alex/tmp/files_to_delete ~ $ # Instead of: ~ $ rm * ~ $ # do this: ~ $ rm ../files_to_delete/*
-rflast. You do not want to accidentally hit
Enterwhen there is a partially typed but valid path on the command line.
~ $ # Don't do this, because you don't want to ~ $ # accidentally hit Enter rigth after "alex": ~ $ rm -rf /home/alex/tmp/* ~ $ # But rather, do this: ~ $ rm /home/alex/tmp/* -rf ~ $ # So if you hit Enter in the middle of it, you will get an error.</span>