Here's part of this xkcd comic strip where the idea is that the author can't write a sort program so he adds code to delete all files

system("rm -rf ./");
system("rm -rf ~/*");
system("rm -rf /");

AFAIK the canonical way to delete everything is to rm/ so that everything starting from root is deleted. Here this is the last command and the two commands before that try to rm the current directory and the contents of the home directory.

JFTR as rm is loaded in the memor it should work and keep working even if necessary variables are removed. After you run rm -rf / from an interactive session your shell should be still working
–
Ulrich DangelMar 14 '13 at 14:38

7

Recent rms will fail on the last command with rm: it is dangerous to operate recursively on ‘/’; other than that rm doesn't require access to any resource after initialization. A reason for using multiple commands might be that the user might have different access permissions to those directories.
–
Stéphane GimenezMar 14 '13 at 14:38

@UlrichDangel, I found out the hard way on Solaris a long time back...
–
vonbrandMar 14 '13 at 17:39

@StéphaneGimenez- Recent versions It will fail like that even with the -f flag?
–
user606723Mar 14 '13 at 18:22

It will. You actually need to use rm --no-preserve-root / for this to actually work
–
MaxMar 14 '13 at 19:03