大多數時候,我們中沒有人願意執行一個會破壞我們的作業系統並迫使我們重新安裝它們的操作。但是,如果這樣的行為很容易發生,即使是使用者的意外呢?今天的超級使用者問答帖子回答了一個困惑讀者的問題。
今天的問答環節是由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***
... 下面是一個示例shell指令碼/etc/profile,每次使用者登入時都會執行該指令碼。想象一下用手輸入這些命令! ...
...果其他方法都失敗了,請閱讀手冊。Linux和Mac上的命令列使用者知道,他們可以鍵入“man”,然後輸入命令名來檢視該命令的詳細說明。這些手冊頁很有用,但很冗長。有時,你所需要的只是一個簡短的命令解釋,以重新整理你...
作為一個計算機使用者,如果你必須定義一個快捷方式,你可能會說它是指向檔案、資料夾或應用程式的指標,對嗎?沒錯。 ...
...無法單獨討論,不過如果您感興趣,Symantec論壇上的一位使用者已經解釋了很多。通常,可以將System32的大部分內容分成兩組: ...
... 然而,即使對於長期使用者,也有太多的命令要提交到記憶體中。這就是為什麼我們準備了這個方便的Linux命令備忘單。如果您想執行其中的幾個,請檢視如何在帶螢幕的Linux終端上執行多工...
想在Linux系統上新增使用者但不知道如何新增?在Linux上使用命令列介面管理使用者無疑是一項複雜的工作。而對於初學者來說,即使新增新使用者也是一場噩夢。 ...
許多Linux使用者從未聽說過pushd和popd,但它們已經存在了很久。它們還可以顯著加快在命令列上導航目錄的過程。我們將教你如何使用它們。 什麼是推送和彈出(pushd and popd)? BillJoy在其1978年的C Shell中的創新之一是目錄堆疊的...
...和潛在的缺陷。 它們已經在使用了 將安全性構建到多使用者作業系統中會出現幾個難題。以密碼(看似)的基本概念為例。它們都必須儲存起來,這樣每次有人登入時,系統就可以將他鍵入的密碼與儲存的副本進行比較。顯...
在Linux上刪除一個使用者所涉及的事情比你想象的要多。如果您是系統管理員,則需要從系統中清除帳戶及其訪問許可權的所有跟蹤。我們會告訴你要採取的步驟。 如果您只想從系統中刪除使用者帳戶,而不想結束任何正在執行...