Tag Archives: rm

The power of misused rm command on Ubuntu Linux

Some @##&% posted rm based commands on UF yesterday. The intent was to deliberately nuke new users systems, as the posts were in the beginners section, in unanswered, or 1-2 replies threads.

In addition to be banning the accounts and IPs and removing all the posts, we turned back on a confirmation email registration process. Many thanks to all the regular members who have been helping, placing warning in their sigs, posting in threads and reporting the infamous posts.

It is so frustrating to see this happening. There must be at least 10 pages of reports and infractions sitting around the staff area for the two posting waves we had. Breaking someone else’s system, I just do not see how funny it is. Is it for fame? Power? Out of boredom? See K.Mandla’s blog article for some interesting insights.

In any case, educating the new users is one of the answers we can give. Here is a little tutorial, based on a forum’s post where Aysiu has explained the rm command.

Excerpt from man rm:

NAME
       rm - remove files or directories
-f, --force
              ignore nonexistent files, never prompt
 -r, -R, --recursive
              remove directories and their contents recursively

So any command based on rm -rf will recursively remove files without asking for a confirmation. As everything is a file on Linux (the concept of directories does not really apply, each “directory” is a file) you can wipe everything that is sitting in the “directory” you are running the command from. Guess what happens if you run it in your /home..

Examples – DO NOT RUN THEM

Now, a precise file to delete can be indicated:

rm -rf /home
sudo rm -rf /

The first one will wipe /home, regardless from where the command is running. The second one will wipe the entire root file system (/). Admin privilege is required to access /, gained with sudo on Ubuntu.

Basic recommendations

  • Do not run these commands, unless confirmed by long time members. rm is useful and is sometimes the only solution.
  • Backup, backup and backup again. On at least two separate removable devices for important stuff. The only user I am aware of being caught in the process had everything backed up.
  • Be curious and search for commands you do not understand, either with man or a search on Google or UF. You’ll improve your knowledge and skills at the same time.
  • Read the UF announcement

Oh well.. One of these days.

PS: thanks to Stefano Rivera, see the comments below :)