Make rm command move deleted items to Trash

One thing I learned at the cost of having to rebuild an entire server (luckily only a test lab one – but still annoying) is that the command “rm -rf” can be quite dangerous, especially when you’re logged in as root 🙂

But had I done the following, things may have turned out slightly better:

  • In your home directory (/root in this example), add the following line to the (hidden) file .bashrc:
    # create an alias so that rm actually moves deleted stuff to Trash
    alias rm=’mv –target-directory ~/.Trash’

Basically, when you now run the rm command to delete a file or folder, you will actually invoke the mv command to move the file or folder to Trash.

I’m not sure (yet) how you would do that so it applies to all system users, but it must be pretty easy.

%d bloggers like this: