大多数时候,我们中没有人愿意执行一个会破坏我们的操作系统并迫使我们重新安装它们的操作。但是,如果这样的行为很容易发生,即使是用户的意外呢?今天的超级用户问答帖子回答了一个困惑读者的问题。
今天的问答环节是由SuperUser提供的,SuperUser是Stack Exchange的一个分支,是一个由社区驱动的问答网站分组。
超级用户读者方兴想知道为什么Linux允许用户删除根目录:
When I installed Linux on my computer for the first time, I always liked to use root because I did not need to add sudo and enter my password every time I executed a command that needed root level permissi***.
One day, I just wanted to remove a directory and ran rm -rf /, which “broke” my system. I have been wondering why Linux’s designers did not block such a dangerous command from being run so easily.
为什么Linux允许用户删除根目录?
超级用户贡献者Ben N为我们提供了答案:
Why should it block you from doing whatever you want with your own computer? Logging in as root or using sudo is literally saying to the machine, “I know what I am doing.” Preventing people from doing dubious things usually also prevents them from doing clever things (as expressed by Raymond Chen).
Besides, there is one singularly good reason to allow a user to torch the root directory: decommissioning a computer by completely erasing the operating system and file system. (Danger! On some UEFI systems, rm -rf / can brick the physical machine too.) It is also a reasonable thing to do inside a chroot jail.
Apparently, people accidentally ran the command so much that a safety feature was added. rm -rf / does nothing on most systems unless –no-preserve-root is also supplied, and there is no way that you can type that by accident. That also helps guard against poorly-written but well-intentioned shell scripts.
有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案吗?在这里查看完整的讨论主题。
图片来源:Wikimedia Comm***
...性。了解更多关于Bash-on-Windows的信息,从您应该如何以及为什么安装它,到您可能不知道的隐藏特性。 ...
...对于长期用户,也有太多的命令要提交到内存中。这就是为什么我们准备了这个方便的Linux命令备忘单。如果您想运行其中的几个,请查看如何在带屏幕的Linux终端上执行多任务。 ...
...多数人第一次在电脑上使用Linux时都会感到困惑。这就是为什么如果您要从任何其他操作系统切换到Linux,选择正确的发行版是很重要的。 ...
...安装其他包管理器,比如Yay。与Pacman不同,这些包管理器允许您从官方的Arch存储库和AUR(Arch用户存储库)添加新包。 ...
...到了无法挽回的失落,这是你永远都会感激的。 这就是为什么testdisk是如此方便的实用工具。当你通过菜单,可以开始恢复文件,很容易陷入一个节奏的突出显示,c,c,重复。
...后,您将有一种在目录之间跳转的超快速方法。 这就是为什么我们要挂在命令行上。效率很高,对吧? 相关:您应该知道的37条重要的Linux命令
...念,我们创建了一个名为htg的小程序。它位于dave用户的根目录中,并且没有SUID位。当它被执行时,它显示真实有效的用户id(UID)。 真正的UID属于启动程序的人。有效ID是程序运行时所使用的帐户,就像启动程序时所使用的帐...