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.
Why not just rm
/
?
Best Answer
If you start at the very top, it's possible that you'll wipe out something that
rm
(or some other critical part of the system) needs to continue, and the evilness will be left incomplete.These commands will make sure that at least the cwd and the user's home directory are gone before going nuclear.