This is not a support request, so mods please don’t delete this. I was just curious about this so I asked.
Is there any legitimate reason to use rm -rf /? If so under what condition would you want to do so?
The reason I ask is that rm -rf / will destroy your root file tree only if if you provide a --no-preserve-root argument. But if using it is so dangerous, why not disallow the command from deleting root altogether?
I once watched a gobby consultant type in “rm -rf /*” on the console of an IMB RS6000 running AIX, in front of a client, while bragging about how the UNIX system was so great it could withstand such a command. I cautioned him (in front of said client) not to press return, a caution that was met with much displeasure and an insistence that of course he would not actually press return … at which point he did in fact, accidentally press return.
I immediately left the building, however I did hear that he was on-site for the following three days and never returned to our office (!)
In general it’s Linux’s job to do what it’s told and the user’s job not to be an idiot careless. … there are always special cases, but you never know when someone might actually want to do something that you think they shouldn’t … Off the top of my head, I think you can mount an overlay filesystem on top of “/”, which is how “live CD” systems used to work … in which case “rm -rf /” should strip any changed files from your system (?) leaving it running on the underlying (possibly read-only) file-system … or if you mount “/” read-only, “rm -rf /” might remove any RW files from non-root mount points. (although I’ve not tried it)