【問題】root賬號的UID和GID永遠是0嗎?


參考:Does the root account always have UID/GID 0?

這實際上是2個問題

Does the superuser account always have uid/gid 0/0 on Linux?

Yes. As is pointed out by Rich Homolka in a comment, there's code in the kernel which explicitly checks for uid 0 when needing to check for the root user, which means that root always has at least uid 0.

Is the name of the user account with uid 0 always root?

No. root只是一個名稱,列在/ etc / passwd或其他一些保存身份驗證存的地方。 你也可以把整個賬戶改為admin,操作系統本身也不會關心,但某些應用程序可能不太喜歡admin,因為他們希望存在名為root的特權帳戶。 在Linux系統上,把uid 0帳戶稱為root是一個非常強烈的約定,但系統不需要它(盡管某些用戶空間軟件可能需要它,可能包括系統管理程序)。

值得注意的是,正如Simon Richter所指出的那樣,在BSD上經常存在第二個uid 0帳戶,按慣例命名為toor(向后拼寫為“root”)。 例如,FreeBSD使用它為root用戶提供自定義shell設置,使root用戶保留一個默認shell,該shell保證存在於系統的根分區上(對於恢復目的很有用)。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM