We all know about the powerful but dangerous rm -rf command, that will recursively remove all files within a directory. If run in the wrong directory by accident, it can wipe it out and if run from /, you will lose every last bit of your operating system. For many, it is a command best avoided as there are other options.
I am a person that in the terminal, am in the habit of hitting the up-arrow-key
to access a previously entered command in order to repeat it.
The other day, i did something unusual and deviated from my usual way of doing things. In cleaning my cache, instead of entering rm -rf /home/.config/cache
I cd'd to the cache folder and then just entered rm -rf. No problems, made the cache folder clean n shiny.
But later, when I hit the up-arrow
to redo a command, I very nearly hit enter a moment too soon. Since the rm -rf command was all there was on that line, it would have wipe out all data in my Home Directory and would not ask "Are you sure? (y/n)."
If you are a person that up-arrow keys in terminal, a quick tip: only ever use the rm -rf command with the file path. That way if you bap it by accident, it will only try to remove the contents of a folder which already has been cleaned.
And if ever you do cd to the directory, then run the command before you realize what you have done; It would be wise to open the bash_history file in your home folder and delete that line afterward to prevent horrors.