Fork me on GitHub

【问题】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保证存在于系统的根分区上(对于恢复目的很有用)。

posted @ 2018-10-19 10:41  克拉默与矩阵  阅读(5360)  评论(0编辑  收藏  举报