1

On my CentOS 6.9 box I've just spotted that rm myfile no longer asks me if I really want to delete it, it just deletes it.

I've run alias and there's nothing to do with rm there.

What else could be making it act as if I'd supplied -f when I haven't?

Codemonkey
  • 1,086
  • 4
  • 19
  • 41

1 Answers1

2

Generally, rm does not ask for confirmation before deletion. To force it to ask for confirmation, you can use the -i switch or define an alias like:

alias rm='rm -i'

There are cases when it asks for confirmation without specifying any option like -i or -f such as when you are removing a read-only file (no write permission).

Khaled
  • 36,533
  • 8
  • 72
  • 99
  • Ah that makes sense. I managed to nuke my .bashrc file the other day so I must have previously had an alias set up in there that WAS enabling the confirmation, e.g. `alias rm="rm -i"` – Codemonkey Sep 28 '17 at 08:18
  • BTW typically for root 3 aliases are set : `alias rm='rm -i'` , `alias cp='cp -i'` & `alias mv='mv -i'` – HBruijn Sep 28 '17 at 08:19
  • Thanks. I look at a .bashrc from another box that I have and saw those too. Much appreciated to both of you! – Codemonkey Sep 28 '17 at 09:53
  • Is there a way to get sudo to honor the alias? – duct_tape_coder Aug 08 '23 at 15:24