How far will you get with an 'rm -rf /' command?
If you have rm
from GNU coreutils (most probably if it's a regular Linux distro), rm -rf /
will be refused by the built-in protection (according to manpage and Wikipedia, haven't tried that).
You can override this protection with --no-preserve-root
. rm
will then remove everything it possibly can, without stopping after having attempted to remove every single file. Of course it won't remove virtual filesystems like /proc
and /sys
, but that's irrelevant – it will remove everything on your disk.
After the command finishes, you disk will be wiped empty, including the OS. The kernel and current processes will continue to run from memory, but many processes will die because they will fail to access some file. The OS will fail to boot next time.
For those who like to do stuff like this visually while listening to techno music.
Running rm- rf on Linux (video)
Bonus points if you can name the processes as they start dying.
Set up a VM and try for fun?
It'll go quite far... if you're using a gui you might have fun noticing things degrade more visibly. (icons on menus stop loading etc.)
If you let it go, the OS will pretty much be beyond recovery though you may be able to get some data back easily.
Either way, you'll be wanting to do a reinstall of the OS.
Well, trying it on http://bellard.org/jslinux/ produces:
rm: can't remove '/dev/pts': Device or resource busy
rm: can't remove '/dev': Directory not empty
rm: can't remove '/proc/swaps': Operation not permitted
rm: can't remove '/proc/kallsyms': Operation not permitted
rm: can't remove '/proc/dma': Operation not permittedSNIP 881 entries
rm: can't remove '/proc/149/oom_adj': Permission denied
rm: can't remove '/proc/149': Operation not permitted
rm: can't remove '/proc': Device or resource busy
rm: can't remove '/tmp': Device or resource busy
rm: can't remove '/': Device or resource busy