What happens if you run rm -rf / on Linux?
You used to be able to wipe a hard drive pretty easy with the well known 'rm -rf /' command. By wipe, it literally means everything is deleted off the hard drive leaving only what is currently running in RAM. This is both a joke and often times a Linux user's worst nightmare- especially as a result of a bad script or makefile run with superuser privileges. However, GNU coreutils has been updated to prevent this exact command with special treatment as of version 6.4.
$ sudo rm -rf / rm: it is dangerous to operate recursively on ‘/’ rm: use --no-preserve-root to override this failsafe
However, there's a notable and easy way around this besides using the special option. For example, cd to root first and use rm -rf *. You get the same end result in a just as accidental and easy way.
$ cd / $ sudo rm -rf * rm: cannot remove ‘dev/mqueue’: Device or resource busy rm: cannot remove ‘dev/hugepages’: Device or resource busy rm: cannot remove ‘dev/shm’: Device or resource busy rm: cannot remove ‘dev/pts/7’: Operation not permitted rm: cannot remove ‘dev/pts/0’: Operation not permitted rm: cannot remove ‘dev/pts/17’: Operation not permitted rm: cannot remove ‘dev/pts/16’: Operation not permitted rm: cannot remove ‘dev/pts/15’: Operation not permitted rm: cannot remove ‘dev/pts/14’: Operation not permitted rm: cannot remove ‘dev/pts/13’: Operation not permitted rm: cannot remove ‘dev/pts/12’: Operation not permitted rm: cannot remove ‘dev/pts/10’: Operation not permitted rm: cannot remove ‘dev/pts/8’: Operation not permitted rm: cannot remove ‘dev/pts/6’: Operation not permitted rm: cannot remove ‘dev/pts/9’: Operation not permitted rm: cannot remove ‘dev/pts/3’: Operation not permitted rm: cannot remove ‘dev/pts/4’: Operation not permitted rm: cannot remove ‘dev/pts/2’: Operation not permitted rm: cannot remove ‘dev/pts/11’: Operation not permitted rm: cannot remove ‘dev/pts/1’: Operation not permitted rm: cannot remove ‘dev/pts/ptmx’: Operation not permitted ...
After that, expect all sorts of fun and odd things to happen. So, fire up a virtual machine and give it try yourself.