# how to forbid a command without a permission

I intended to delete all the backup files in a directory, so I was going to type rm *~ in the terminal. Unfortunately, I hit the Enter before hitting the tilde and unhappy things happened. Although, I've recovered all deleted files I really don't want it to happen again. Could I forbid the execution of such a command unless being granted a permission, like that of a superuser?

-
Obvious comment, but learn and use distributed version control, and these things will become less of an issue. See also trash-cli if available for your distribution. See also Where do files go when the rm command is issued?. –  Faheem Mitha Mar 28 '12 at 12:34

I am not a fan of overriding built-in commands, but in my .bashrc (part of Tilde, my "dot files") I explicitly do this:

alias rm='rm -i';


This makes rm ask for permission before deleting. It has saved me a few times. You can always override with rm -f.

-
Efficient solution, which I thought most people had... With ZSH, aliases have to be put in ~/.zshrc like this: alias rm='rm -i' or alias rm="rm -i" –  tiktak Mar 28 '12 at 12:15

In Bash I simply escape the rm command to override the -i option. Like so: \rm file*

I love the -i option. It too has saved my from myself.

-
nice tip, cheers! –  manuzhang Mar 29 '12 at 2:48
In other words, learn to pause and double check that you got it right whenever you start typing an rm with wild cards.