Kāpēc Linux ļauj lietotājiem noņemt saknes direktoriju?

Satura rādītājs:

Kāpēc Linux ļauj lietotājiem noņemt saknes direktoriju?
Kāpēc Linux ļauj lietotājiem noņemt saknes direktoriju?

Video: Kāpēc Linux ļauj lietotājiem noņemt saknes direktoriju?

Video: Kāpēc Linux ļauj lietotājiem noņemt saknes direktoriju?
Video: LW31 AGPTEK Smart Watch IP68: Things To Know Before Buy // For Android and iPhone - YouTube 2024, Aprīlis
Anonim
Lielāko daļu laika neviens no mums nevēlas veikt darbību, kas burtiski pārtrauks mūsu operētājsistēmas un liek mums to no jauna instalēt. Bet ko tad, ja šāda darbība varētu viegli notikt pat nejauši lietotāja pusē? Šodienas SuperUser Q & A ziņai ir atbilde uz sajaukt lasītāja jautājumu.
Lielāko daļu laika neviens no mums nevēlas veikt darbību, kas burtiski pārtrauks mūsu operētājsistēmas un liek mums to no jauna instalēt. Bet ko tad, ja šāda darbība varētu viegli notikt pat nejauši lietotāja pusē? Šodienas SuperUser Q & A ziņai ir atbilde uz sajaukt lasītāja jautājumu.

Šodienas jautājumu un atbilžu sesija mums priecājas par SuperUser - Stack Exchange dalību, kas ir kopienas vadīta Q & A tīmekļa vietņu grupa.

Jautājums

SuperUser lasītājs fangxing vēlas uzzināt, kāpēc Linux ļaus lietotājiem noņemt saknes direktoriju:

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.

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.

Kāpēc Linux ļauj lietotājiem noņemt saknes direktoriju?

Atbilde

SuperUser atbalstītājs Ben N ir atbilde mums:

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.

Vai kaut ko pievienot paskaidrojumam? Skatieties komentāros. Vēlaties lasīt citas atbildes no citiem tehnoloģiju savvy Stack Exchange lietotājiem? Šeit skatiet pilnu diskusiju pavedienu.

Attēlu kredīts: Wikimedia Commons

Ieteicams: