Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn on warning on rm command?

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?

like image 852
S Wang Avatar asked Dec 15 '25 00:12

S Wang


1 Answers

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

like image 61
dlmeetei Avatar answered Dec 16 '25 22:12

dlmeetei



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!