要永久修改 CentOS 的 ulimit 设置,您需要编辑系统配置文件
/etc/security/limits.conf 文件:sudo vi /etc/security/limits.conf username、domain 和 soft/hard 值。例如,如果您想要为名为 “myuser” 的用户设置文件描述符限制为 65535,您可以添加以下行:myuser soft nofile 65535 myuser hard nofile 65535 这里的 soft 是软限制,用户可以在运行时更改它。hard 是硬限制,用户无法超过此限制。nofile 表示文件描述符限制。
如果您想要为所有用户设置相同的限制,可以使用 * 代替用户名:
* soft nofile 65535 * hard nofile 65535 保存并关闭文件。
为了让更改生效,您需要重新登录或重启系统。现在,新的 ulimit 设置应该已经生效。
注意:这些更改仅适用于通过 PAM(Pluggable Authentication Modules)进行身份验证的用户。如果您的系统使用其他身份验证方法,您可能需要在相应的配置文件中进行更改。