Skip to main content

This is what happens when you run rm -rf /

(Updated: )

Note: This blog was migrated from a previous blog.

I got bored so I decided to run rm -rf / --no-preserve-root to see what would happen. In a virtual machine of course since using my actual computer would be stupid. So, here’s what happens

What Does rm -rf/ --no-preserve-root Mean Anyway?

rm -rf / --no-preserve-root does the following,

  • rm is the remove command
  • -r means recursive delete allowing you to delete a directory.
  • -f means force delete
  • / is the root directory (top level) and
  • --no-preserve-root lets you confirm that you actually want to delete the directory since deleting the root directory isn’t really something you would normally do.

To actually run the command, you need to add sudo which tells Linux that you want to run this with root privileges, letting you do anything you want.

What The Command Did

Before I ran the command, I opened up the following.

  • the terminal,
  • a web browser,
  • a YouTube video with some Creative Commons Music by Kevin MacLeod,
  • An ssh connection to myself
  • Libre Office😱 and
  • Visual Studio Code.

Initially, I get a lot of permission denied errors. Sometime later, Unity’s side dock loses the unopened applications before going away altogether. Soon after that, the sound stops working before the delete stops.

The aftermath is as follows.

  • The terminal was still running, although none of the Linux commands worked. cd did work, but only to move to root.
  • The ssh connection was still alive and well. It’s just that once I logged out of it, I couldn’t open it up again.
  • VS Code still worked although the integrated terminal didn’t work.
  • The web browser still worked and maintained its connection. The issue was that the fonts were deleted so I couldn’t inspect anything from the console but worked on the website.
  • I couldn’t pass the shutdown signal from either the terminal or Virtual Box, meaning that I had to “pull the plug”.
  • When I tried to restart, I got this grub rescue interface. With that, I can assume that rm -rf / does really delete everything. The only reason I can think of as to why some things kept working was that they were loaded into memory, allowing me to use them as they remained in memory.

So there you have it, rm -rf / --no-preserve-root does exactly what you would expect. As I said earlier, this needs to be run in sudo and --no-preserve-root in order to work or else you’ll have insufficient privileges to do so.

If you feel like trying this out yourself, get yourself Ubuntu and run it in a virtual machine like Virtual Box. Or you can do it on your own computer. T’s up to you.