在 Debian 里,系统级(全局)ulimit 并不是在某一行 ulimit 命令里改,而是通过 PAM + systemd/limits 配置 来做的。常见位置和方式如下:
这是 最标准的系统级配置方式。
/etc/security/limits.conf
示例(对所有用户生效):
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535
说明:
* 表示所有用户(也可写用户名、组 @group)soft:软限制(用户可临时超过,但会警告)hard:硬限制(不能超过)nofile:打开文件数nproc:进程数⚠️ 注意:
如果是 系统服务 / 守护进程,limits.conf 不生效,需要改 systemd:
/etc/systemd/system.conf
或:
/etc/systemd/user.conf
示例:
DefaultLimitNOFILE=65535
DefaultLimitNPROC=65535
修改后必须重启:
systemctl daemon-reexec
# 或重启系统
如果你只想给某个服务改:
/etc/systemd/system/xxx.service
[Service]
LimitNOFILE=65535
LimitNPROC=65535
然后:
systemctl daemon-reload
systemctl restart xxx
ulimit -a
cat /proc/<pid>/limits
如果你能说清楚:
我可以给你更精确的改法。