3

I recently installed Ubuntu and find that when I delete things in terminal using

rm file

there is no warning asking me to confirm the step. I did not use the -f flag. It feels vulnerable to accidental deletion in this way. I searched online and didn't find the reason for this. How can I turn on the warning?

S Wang
  • 213
  • 3
  • 11
  • 2
    the reason is that linux is assuming that you know what you are doing (btw: `del` in Windows command-prompt don't ask you either ... this is kindof the expected behavior for as long as I can remember using computers) – Random Dev Feb 03 '16 at 09:35
  • 2
    in case you are still wondering: the `-i` switch should ask you (if you really want) [see here](http://www.computerhope.com/unix/urm.htm) – Random Dev Feb 03 '16 at 09:37
  • 1
    But in the man page of rm it still defines the -f option clearly. Btw the previous linux system I used will prompt a warning message. I guess it is dependent on the shell. But since they all use bash, why is there difference? – S Wang Feb 03 '16 at 09:39

1 Answers1

4

Put alias rm='rm -i' in your ~/.bash_rc or rc file of your shell. Then source ~/.bash_rc.

It will start asking for confirmation and whenever you don't want this. Use one of the following

$\rm file
$command rm file

\ escapes the alias and I like \ better due to it's lesser typing

This explanation assumes that you are using bash. The name for rc file may differs based on your shell

dlmeetei
  • 9,905
  • 3
  • 31
  • 38