If I am logged in as root in a linux system and I run command rm -rf on / folder, should it remove all the files? also the kernel?

Just curious about it :P

link|improve this question
feedback

migrated from stackoverflow.com Sep 21 '10 at 15:05

This question came from our site for professional and enthusiast programmers.

4 Answers

Looks like the result will depend on the distro. See:

Try it yourself (in a VM) :)

link|improve this answer
feedback

Yes it would, some systems have protection against it though, like Solaris 10.

link|improve this answer
feedback

I wouldn't try this unless you plan on pulling out all of your hair later.

link|improve this answer
3  
-1. At least it will satisfy his curiosity. – Anonymous Sep 21 '10 at 15:01
feedback

It may or may not remove every file, but unless the OS is filtering it, chances are you'll end up with an effectively unusable system. In particular, you probably won't be able to remove files or devices that are in use at the time you execute the command.

If your goal is to completely hose a running system, this should do the trick.

If you actually want to delete everything on the disk, you should boot from a different device such as a LiveCD or a USB drive and then have your way with the target disk.

If you are doing this because you don't want to leak confidential/sensitive information, I would suggest something like Darik's Boot and Nuke instead of playing around with "rm".

If you just want to start again with an empty disk, instead of "rm", I would just make a new filesystem on that block device. This will be much faster than an "rm" on an entire filesystem or multiple filesystems.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown