To avoid catastrophic data loss, readers should NOT run this, nor any variations on it!

I would like to understand what does this command do: sudo rm -rf/*

  • 2
    It deletes everything on your disk(s). Do not run this unless you want to destroy your installation and lose all files on your computer! – Byte Commander Jun 24 '19 at 11:01
  • 6
    It will give an error because of a typo. – xiota Jun 24 '19 at 11:05
  • 1
    @Helen the typo is that there should be a space between the -rf and /*. – Arronical Jun 24 '19 at 11:31
  • 1
    Helen, every command on a ubuntu system has thorough documentation: see man sudo and man rm – glenn jackman Jun 24 '19 at 11:38
  • 1
    @Arronical The command didn't come out of nowhere. It's hard to believe OP did not know it is potentially dangerous. If OP is a newbie, it would have come from a list of commands known to be dangerous. If OP is not a newbie, then this could be an intentional attempt to get other people to run the command. – xiota Jun 24 '19 at 11:39

As presented, the command will give an error because of a typo.

sudo rm -rf/*
[sudo] password for ___: 
rm: invalid option -- '/'
Try 'rm --help' for more information.

Without the typo, the command would attempt to delete all files on the system. It would throw errors for some files, which are inherently undeletable, such as some contained in /proc, /sys, /dev, or read-only file systems.

Although someone else has already indicated in comments how to correct it, I will not do so in this answer because it might cause some newbies to destroy their systems.

For more information about the rm command, see man rm.

  • rm = remove files
  • -r = recursive
  • -f = force (ie. don't ask for confirmation)
  • The options were grouped as -rf to save typing.
  • /* = files to start removing; ie. start in / or root directory
  • sudo elevates privileges - so the user will have write permission to everything.

In summary, that command will delete every single file on your system without any sort of confirmation.

You can run man rm to read the manual page for rm.

  • 1
    As already stated; it's a command you should NOT try unless it's a VM or machine you are destroying.. – guiverc Jun 24 '19 at 11:06
  • 1
    This answer is incorrect. The command in the question has a typo that would prevent it from running as this answer indicates. – xiota Jun 24 '19 at 11:34
  • 1
    I chose to ignore the typo. I hoped it (typo) was made on purpose so idiots don't try it out, and chose not to correct that issue as it didn't impact what I was saying. – guiverc Jun 24 '19 at 12:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.