Stop accidental deletions on Linux

Have you ever logged into a Linux box as root and accidentally typed ‘rm *’ then regretted it for the rest of the day?

There is a simple way to ensure you get a chance to change your mind, using your favourite text editor (I use vim), edit the file /etc/profile and add the following three lines to the end:

alias rm=’rm -i’
alias cp=’cp -i’
alias mv=’mv -i’

This tells cp and mv to ask for confirmation before overwriting anything and tells rm to ask for confirmation on each delete.

 

Leave a Reply

Your e-mail address will not be published. Required fields are marked *