為什麼linux允許使用者刪除根目錄?

大多數時候,我們中沒有人願意執行一個會破壞我們的作業系統並迫使我們重新安裝它們的操作。但是,如果這樣的行為很容易發生,即使是使用者的意外呢?今天的超級使用者問答帖子回答了一個困惑讀者的問題。...

為什麼linux允許使用者刪除根目錄?

大多數時候,我們中沒有人願意執行一個會破壞我們的作業系統並迫使我們重新安裝它們的操作。但是,如果這樣的行為很容易發生,即使是使用者的意外呢?今天的超級使用者問答帖子回答了一個困惑讀者的問題。

今天的問答環節是由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***

  • 發表於 2021-04-08 21:37
  • 閱讀 ( 24 )
  • 分類:網際網路

你可能感興趣的文章

如何在ubuntu中加密檔案和資料夾

... 在Linux上,您使用什麼方法加密檔案和資料夾?你找到我們沒提到的其他工具了嗎? ...

  • 發佈於 2021-03-11 16:31
  • 閲讀 ( 59 )

什麼是shell指令碼,為什麼要使用它

... 下面是一個示例shell指令碼/etc/profile,每次使用者登入時都會執行該指令碼。想象一下用手輸入這些命令! ...

  • 發佈於 2021-03-13 04:53
  • 閲讀 ( 54 )

如何在linux和macos上將手冊頁縮短為可讀的解釋

...果其他方法都失敗了,請閱讀手冊。Linux和Mac上的命令列使用者知道,他們可以鍵入“man”,然後輸入命令名來檢視該命令的詳細說明。這些手冊頁很有用,但很冗長。有時,你所需要的只是一個簡短的命令解釋,以重新整理你...

  • 發佈於 2021-03-14 01:21
  • 閲讀 ( 54 )

什麼是符號連結(symlink)?如何在linux中建立一個

作為一個計算機使用者,如果你必須定義一個快捷方式,你可能會說它是指向檔案、資料夾或應用程式的指標,對嗎?沒錯。 ...

  • 發佈於 2021-03-19 23:12
  • 閲讀 ( 51 )

WindowsSystem32目錄:它是什麼以及為什麼不能刪除它

...無法單獨討論,不過如果您感興趣,Symantec論壇上的一位使用者已經解釋了很多。通常,可以將System32的大部分內容分成兩組: ...

  • 發佈於 2021-03-20 03:47
  • 閲讀 ( 52 )

linux命令參考備忘單

... 然而,即使對於長期使用者,也有太多的命令要提交到記憶體中。這就是為什麼我們準備了這個方便的Linux命令備忘單。如果您想執行其中的幾個,請檢視如何在帶螢幕的Linux終端上執行多工...

  • 發佈於 2021-03-22 04:06
  • 閲讀 ( 57 )

如何在linux中新增使用者

想在Linux系統上新增使用者但不知道如何新增?在Linux上使用命令列介面管理使用者無疑是一項複雜的工作。而對於初學者來說,即使新增新使用者也是一場噩夢。 ...

  • 發佈於 2021-03-26 23:29
  • 閲讀 ( 69 )

linux下如何使用pushd和popd

許多Linux使用者從未聽說過pushd和popd,但它們已經存在了很久。它們還可以顯著加快在命令列上導航目錄的過程。我們將教你如何使用它們。 什麼是推送和彈出(pushd and popd)? BillJoy在其1978年的C Shell中的創新之一是目錄堆疊的...

  • 發佈於 2021-04-02 13:29
  • 閲讀 ( 40 )

如何在linux上使用suid、sgid和sticky位

...和潛在的缺陷。 它們已經在使用了 將安全性構建到多使用者作業系統中會出現幾個難題。以密碼(看似)的基本概念為例。它們都必須儲存起來,這樣每次有人登入時,系統就可以將他鍵入的密碼與儲存的副本進行比較。顯...

  • 發佈於 2021-04-02 14:48
  • 閲讀 ( 39 )

如何在linux上刪除使用者(並刪除所有跟蹤)

在Linux上刪除一個使用者所涉及的事情比你想象的要多。如果您是系統管理員,則需要從系統中清除帳戶及其訪問許可權的所有跟蹤。我們會告訴你要採取的步驟。 如果您只想從系統中刪除使用者帳戶,而不想結束任何正在執行...

  • 發佈於 2021-04-02 15:16
  • 閲讀 ( 44 )
YuXiaooz
YuXiaooz

0 篇文章

作家榜

  1. admin 0 文章
  2. 孫小欽 0 文章
  3. JVhby0 0 文章
  4. fvpvzrr 0 文章
  5. 0sus8kksc 0 文章
  6. zsfn1903 0 文章
  7. w91395898 0 文章
  8. SuperQueen123 0 文章

相關推薦