为什么 /etc/security/limits.conf 中的 * 不包含 root 用户?

Why * in /etc/security/limits.conf doesn't include root user?

我是 运行 一个 java 程序,作为 root 在 linux 机器上。为了增加 Max open files 限制,我将以下行添加到 /etc/security/limits.conf

*       soft    nofile  1000000
*       hard    nofile  1000000

但是当我用cat /proc/<pid>/limits检查运行程序时,它仍然告诉我Max open files65536。直到我在 /etc/security/limits.conf 中添加了另外两行,Max open files 才可以更改为 1000000

root       soft    nofile  1000000
root       hard    nofile  1000000

我可以看到limits.conf的评论,上面写着

the wildcard *, for default entry.

所以当我使用 * 作为默认条目时,它不包括 root 用户吗?为什么?

正确,它不包括 root 用户。看起来这是设计使然。来自

man 5 limits.conf

NOTE: group and wildcard limits are not applied to the root user. To set a limit for the root user, this field must contain the literal username root.