[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Suggestions for rm



Hi,

Andrew M.A. Cater:
> There's an
>   rm -i
> switch to the rm command. This makes the removal interactive - you get
> an "Are you sure [Y/N]" warning for each file. This is useful for a single
> critical file, less useful when you're removing a hundred logfiles.

After
  alias rm='rm -i'
it is still possible to do non-interactive removals by
  /bin/rm


> On a Red Hat-derived system, this is often aliased to rm by default.

I got mine from SuSE more than 20 years ago.
Since then i have
  alias cp='cp -i'
  alias mv='mv -i'
  alias rm='rm -i'


> That's a great idea - until you move to a system where rm means rm
> immediately.

Probably one will become cautious already by the misconfigured vim there. :))

But yeah. rm on a foreign computer is always hair raising.


> Try and avoid using rm -rf and forced removal.

After such operations i even go back in bash's readline buffer and change
  /bin/rm -rf
to
  rm -r
so that i cannot execute the killer command by overly eager use of the
arrow-up key.


> For the general "I rm'd something critical" - there is no absolute solution.

The backbone of precautions against such a mishap is a sufficiently
complete backup which cannot be easily deleted by mistake.
I prefer DVD and BD media for that. But i'm from last century ...

After "rm -rf /" one probably has to re-install the system first,
unless there is a complete backup image of the system disk. I made one
(when running Debian Live) before i upgraded from Debian 10 to 11.
In the end it was not needed, which is the best thing one can hope for
with a backup.


Have a nice day :)

Thomas


Reply to: