rm -rf

Just a note to you UNIX users out there. rm -rf is a dangerous command. I’ve been warned from so many sources I don’t remember them all, but I still manage to use it somehow. Today I deleted a whole directory of image files on a project at work. (Luckily I had a backup from yesterday, so it was just fine.) But the point remains: Be careful using rm -rf!

I’ve made an alias in my .bashrc file that says rm='rm -i', just so it will make me confirm things in case I actually wasn’t paying attention. (Obviously using -f overrides that, which is convenient when deleting directories but very dangerous at the same time.)

Be careful with sudo, too…

  • Smallgeek

    What is rm -rf anyways? Okay, so I’m not a Linux geek, though I do like penguins. Does it delete files, cause you said you deleted a whole directory of images? Sudo’s the command to run things as the root user, isn’t it? I think you told me that one…

  • Steven

    rm means “remove”, -r is recursive (descend into the directories), and -f means “force”, i.e., don’t ask for a confirmation. So rm -rf will delete the entire directory and everything under it without asking you first.

    Yes, sudo lets you run commands as the root user, which can be quite dangerous if you don’t use discretion.