在 Debian(以及其他 Linux 发行版)里,ulimit 本身不是一个“文件”,而是 shell 内建命令 + 系统/服务配置共同决定的。不过你通常关心的“ulimit 配置文件”主要在以下几个地方:
/etc/security/limits.conf
/etc/security/limits.d/*.conf
(例如 /etc/security/limits.d/30-user.conf)
示例:
* soft nofile 65535
* hard nofile 65535
⚠️ 注意:
systemd 服务 不生效如果是服务(如 nginx、mysql),看这里:
/etc/systemd/system.conf
/etc/systemd/user.conf
示例:
DefaultLimitNOFILE=65535
/etc/systemd/system/xxx.service
[Service]
LimitNOFILE=65535
改完要:
systemctl daemon-reexec
systemctl restart xxx
查看:
ulimit -a
临时修改:
ulimit -n 65535
/proc/sys/fs/file-max
查看:
cat /proc/sys/fs/file-max
修改(临时):
sysctl -w fs.file-max=1000000
永久:
/etc/sysctl.conf
| 目的 | 文件 |
|---|---|
| 用户登录限制 | /etc/security/limits.conf |
| 服务限制 | /etc/systemd/system/*.service |
| 系统最大文件数 | /proc/sys/fs/file-max |
如果你能说 “想给谁(用户 / 服务)改哪种 limit(nofile / nproc 等)”,我可以直接给你一份可用配置。