Tricks for Making rm Safer
Here's a summary of ways to protect yourself from accidentally deleting files:
- Use rm -i, possibly as an alias (articles possibly and ).
- Make rm -i less painful (article ).
- Write a "delete" script that moves "deleted" files to a temporary directory (article ).
- tcsh () has an rmstar variable that makes the shell ask for confirmation when you type something like
rm *
. - Use a more comprehensive "safe delete" program, like the one described in article .
- Use revision control (article ).
- Make your own backups, as explained in article .
- Prevent deletion (or renaming or creating) of files by making the directory (not necessarily the files in it!) unwritable. Article .
If you want to delete with wild abandon, use rm -f (article ).
- ML