要永久修改Debian的ulimit,您需要编辑系统配置文件
打开终端。
使用文本编辑器打开 /etc/security/limits.conf 文件。例如,使用nano编辑器,您可以输入以下命令:
sudo nano /etc/security/limits.conf
<username>、<domain>、soft和hard值。例如,要将用户的最大文件描述符数量设置为65535,请输入:<username> soft nofile 65535
<username> hard nofile 65535
如果您想为所有用户设置ulimit,请使用*替换<username>。
<username> soft nproc 4096
<username> hard nproc 4096
保存并关闭文件。
为了使更改生效,您需要重新登录或重启系统。现在,新的ulimit设置将应用于指定的用户或所有用户。
注意:这些更改仅适用于基于PAM(Pluggable Authentication Modules)的系统。大多数Debian系统默认使用PAM。如果您使用的是非PAM系统,您可能需要修改其他配置文件,例如/etc/pam.d/common-session和/etc/pam.d/common-session-noninteractive。