Sponsors

January 05, 2011

rm command - Adding Security Prompt

It just happened again.... in Unix/Linux Environments a small rm can kill your work of hours or even worse.
A very likely error is putting an / too much at the beginning of the path... and you accidentally hit the wrong folder(s). Gone for ever. Due to there is no trash can like in windows. Bye Bye data.

To avoid these errors, you can trick yourself with setting an alias on rm.


'rm -i' prompts if you really like to delete that file before executing

You can set an alias for rm in your .bashrc file (located in your home folder) or for all users in /etc/bash.bashrc.
For ksh users, look out in your kshrc file.
Entry should look this this:

$ alias rm 'rm –i'

Okay, sounds like for noobs... yeah yeah, we IT professionals should know what we do. Of course, you are right. But anyway, we still are human. And human make mistakes.
So don't let your pride kill your work and try to implement it.

By the way, you can do the same for mv with:

$ alias mv 'mv –i'

See also the rm manpage and mv manpage.

0 Comments:

Post a Comment