有人在 Linux 中真正尝试过 'rm -rf /*' 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10757694/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 06:30:55  来源:igfitidea点击:

Anyone ever actually tried 'rm -rf /*' in Linux?

linuxrm

提问by kevlar1818

Anyone ever actually tried rm -rf /*, or something similar, in Linux? You always hear people joke about it, but I'm curious if it actually executes, and if so, what kind of damage it actually does (not in terms of deleting disk).

有没有人rm -rf /*在 Linux 中实际尝试过或类似的东西?你总是听到人们拿它开玩笑,但我很好奇它是否真的执行了,如果是,它实际上会造成什么样的损害(不是在删除磁盘方面)。

回答by johnshen64

Yes, I did, but only in a VM that could be reverted, just to test and demonstrate (I used to teach OS).

是的,我做到了,但只在可以恢复的 VM 中,只是为了测试和演示(我曾经教过操作系统)。

In older distributions it will execute and wipe out your distribution, but in most newer distributions this will fail.

在较旧的发行版中,它将执行并清除您的发行版,但在大多数较新的发行版中,这将失败。

If you want to try, do it in a place you don't care about, or in a VM that you can revert like me.

如果您想尝试,请在您不关心的地方进行,或者在您可以像我一样恢复的VM中进行。

回答by muffinista

Have I "tried" it? No. Have I done it? Yes, and it's bad. However, if you're lucky:

我“试过”了吗?不,我做到了吗?是的,而且很糟糕。但是,如果你很幸运:

  • You weren't logged in as root, so the damage will be minimal
  • You've installed safe-rmwhich will prevent stuff like this.
  • 您没有以 root 身份登录,因此损失很小
  • 你已经安装了safe-rm来防止这样的事情。

回答by woz

Just for you, I tried it. I got a whole bunch of "rm: cannot remove ...", even with sudo. If you would like to try it out, I recommend VirtualBox and a copy of Ubuntu.

只为你,我试过了。我得到了一大堆“rm:无法删除......”,即使使用 sudo 也是如此。如果您想尝试一下,我推荐 VirtualBox 和 Ubuntu 的副本。

回答by Denys Séguret

Wikipedia : rm -rf (variously, rm -rf /, rm -rf *, and others) is frequently used in jokes and anecdotes about Unix disasters[2] . The rm -rf variant of the command, if run by a superuser on the root directory, would cause the contents of nearly every writable mounted filesystem on the computer to be deleted, up to the point the system itself crashes from missing some crucial file, directory, or the like.

维基百科: rm -rf(各种形式,rm -rf /、rm -rf * 和其他)经常用于有关 Unix 灾难的笑话和轶事[2]。命令的 rm -rf 变体,如果由超级用户在根目录上运行,将导致计算机上几乎每个可写的已挂载文件系统的内容都被删除,直到系统本身因丢失某些关键文件而崩溃,目录等。

http://en.wikipedia.org/wiki/Rm_(Unix)

http://en.wikipedia.org/wiki/Rm_(Unix)

I think some distros added a protection.

我认为一些发行版增加了保护。

EDIT : muffinista gave the link to the protection.

编辑: muffinista 提供了保护的链接。