linux用户的根目录

Most of the time, none of us willingly performs an action that will literally break our operating systems and force us to reinstall them. But what if such an action could easily occur even by accident on the user’s part? Today’s SuperUser Q&A post has the answer to a confused reader’s question.

在大多数情况下,我们没人愿意执行会破坏操作系统并强迫我们重新安装它们的操作。 但是,如果即使是用户意外,也很容易发生这种动作怎么办? 今天的“超级用户问答”帖子回答了一个困惑的读者的问题。

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。

问题 (The Question)

SuperUser reader fangxing wants to know why Linux would allow users to remove the root directory:

超级用户阅读者fangxing想知道为什么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 permissions.

第一次在计算机上安装Linux时,我总是喜欢使用root,因为不需要每次执行需要root级权限的命令时都添加sudo并输入密码。

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.

有一天,我只想删除一个目录并运行rm -rf / ,它“破坏了”我的系统。 我一直在想,为什么Linux的设计人员没有阻止这么危险的命令这么容易地运行。

Why does Linux allow users to remove the root directory?

为什么Linux允许用户删除根目录?

答案 (The Answer)

SuperUser contributor Ben N has the answer for us:

超级用户贡献者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).

为什么要阻止您使用自己的计算机执行任何操作? 从根本上登录或使用sudo对机器说:“我知道我在做什么。” 阻止人们做可疑的事情通常也会阻止他们做聪明的事情(如雷蒙德·陈表示)。

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.

此外,有一个奇特的理由让用户可以破坏根目录:通过完全擦除操作系统和文件系统来停用计算机。 (危险!在某些UEFI系统上, rm -rf /也会使物理机变砖。)在chroot监狱中进行操作也是合理的。

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.

显然,人们不小心运行了命令,以至于添加了安全功能。 rm -rf /在大多数系统上不执行任何操作,除非还提供了–no-preserve-root ,并且您不可能无意间输入该内容。 这也有助于防止编写不良但意图良好的shell脚本。



Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程。

Image Credit: Wikimedia Commons

图片来源: Wikimedia Commons

翻译自: https://www.howtogeek.com/277896/why-does-linux-allow-users-to-remove-the-root-directory/

linux用户的根目录

linux用户的根目录_为什么Linux允许用户删除根目录?相关推荐

  1. Linux Shell脚本专栏_批量创建100用户并设置密码脚本_03

    文章目录 一.简单需求实现流程 1. 添加用户 2. 给用户设置密码 二.企业需求实现流程 2.1. 脚本准备工作 2.2. 企业级脚本 2.2. 需求说明 2.3. 企业级脚本说明 三.实战 3.1 ...

  2. linux 复制包括子目录_【Linux分享】Linux常用命令+教程分享

    今天分享分为两部分 :)PART01 Linux常用命令分享/PART02 关于BD面试经验分享    30mins  Linux Command:PART 1 你本可以张口就来.....本篇内容分享 ...

  3. linux ls不能用_进入Linux世界大门的第二步——Hello World

    前言 上一篇文章(醉卧沙场:进入Linux世界大门的第一步--安装系统),我们让一个从没有用过Linux系统的人安装了系统.那么现在你应该已经boot成功,进入了你的Linux系统.相信很多初次使用L ...

  4. linux mysql 知乎_在 Linux 上安装 MariaDB 或 MySQL | Linux 中国

    开始在 Linux 系统上使用开源的 SQL 数据库吧. (本文字数:2332,阅读时长大约:3 分钟) MariaDB 和 MySQL 都是使用 SQL 的开源数据库,并且共享相同的初始代码库.Ma ...

  5. 嵌入式linux python移植过程_嵌入式linux项目开发(一)——BOA移植

    嵌入式linux项目开发(一)--BOA移植 项目目标:使用BOA.CGIC.SQLite搭建嵌入式web服务器 一.嵌入式web服务器BOA简介 在嵌入式设备的管理与交互中,基于Web方式的应用成为 ...

  6. linux 穿件文件_关于Linux的25件事

    linux 穿件文件 今天是Linux 25年的历史,这是有史以来最成功的软件. 在本周的LinuxCon上,Linux基金会的Jim Zemlin在主题演讲中表达了钦佩,赞美和激动,他说:" ...

  7. linux定时任务每小时_在Linux平台下每5、10或15分钟执行一次定时任务(Cron Job)...

    本文介绍如何在Linux平台下每5.10或15分钟运行一次cron命令,即执行一次定时任务(Cron Job). 前言 Cron job是按指定间隔执行的任务,可以将任务安排为按分钟,小时,每月的某天 ...

  8. linux配置usb主从_基于Linux的USB主/从设备之间的三种通信方式

    随着简单易用的USB接口日益流行,在嵌入式系统中添加对USB接口的支持已成为大势所趋.本文通过介绍Linux中支持USB的各种模块和库,分析了在Linux上利用USB实现高速串口和以太网连接等通信方式 ...

  9. linux配置usb主从_基于Linux的USB 主/从设备之间通讯的三种方式

    转载:http://archive.eet-china.com/www.eet-china.com/ART_8800323770_617693_TA_eda530e7.HTM 随着简单易用的USB接口 ...

最新文章

  1. 我能考虑到的数组(老)方法就这些了(es5)
  2. PMCAFF产品众测 | 对话随手攒CEO聊聊这款产品的设计、推广和改进(活动已结束)
  3. java 扑克牌排序_java 怎么写compareto方法实现扑克牌排序
  4. 路飞学城-python爬虫密训-第三章
  5. travis-ci_使用Travis-CI的SpringBoot应用程序的CI / CD
  6. 用python设计学生管理系统_基于python和tkinter实现的一个简单的学生信息管理系统...
  7. 机器学习/人工智能 知识图谱
  8. staruml java_非常详细的StarUML使用教程,推荐阅读!
  9. 本地更新github项目_【图文说明】将本地项目上传到github上
  10. python 生成随机数: 随机整数,随机小数,0-1之间的小数
  11. centos6.5解决方案-1
  12. Vim下的插件管理工具pathogen简介
  13. OpenJDK8编码代码三合一:x86/Arm/Mips
  14. 一步一步创建ASP.NET MVC5程序[Repository+Autofac+Automapper+SqlSugar](十一)
  15. Android资源,国内镜像站点,博客文章等
  16. Google Earth Engine(GEE)合成长时序的月NDVI与LST
  17. 一、IOS CocoaPods详细使用方法
  18. 分析各渠道广告,建立评分模型以及找到优质渠道的特性
  19. 2021年茶艺师(中级)考试报名及茶艺师(中级)考试APP
  20. msql中常用的DDL语句

热门文章

  1. mysql010函数使用.单行函数.多行函数
  2. pymssql出现的错误
  3. angelica类似_亲爱的当归(Angelica)是第一个让我哭泣的VR体验
  4. 记一次 Vue2 迁移 Vue3 的实践总结
  5. hello,你知道获取元素有哪几种方式吗?
  6. 洛谷 P1414 又是毕业季II (多个数的最大公因数)
  7. React 重温之 组件生命周期
  8. 流水线上的思考——异步程序开发模型(2)
  9. Oracle Code登录北京 代码盛宴邀你high起来|免费报名
  10. MongoDB中的分组