在 Debian(以及其他 Linux 发行版)中,修改 ulimit 后是否需要重启,取决于你修改的是哪里、以及作用于谁。
下面分情况说明:
ulimit -n 65535
常见文件:
/etc/security/limits.conf/etc/security/limits.d/*.conf示例:
* soft nofile 65535
* hard nofile 65535
生效方式:
logout
# 或
su - 用户名
如果是系统服务(如 nginx、mysql):
[Service]
LimitNOFILE=65535
然后:
systemctl daemon-reload
systemctl restart 服务名
✅ 不需要重启系统
/etc/systemd/system.conf
/etc/systemd/user.conf
DefaultLimitNOFILE=65535
修改后:
systemctl daemon-reexec
⚠️ 已运行的服务仍需重启
sysctl -w fs.file-max=1000000
或:
/etc/sysctl.conf
| 修改位置 | 是否需重启系统 | 是否需重新登录/重启服务 |
|---|---|---|
| 当前 shell | ❌ | ❌ |
| limits.conf | ❌ | ✅(重新登录) |
| systemd service | ❌ | ✅(重启服务) |
| sysctl | ❌ | ❌ |
如果你愿意,可以告诉我:
我可以给你最合适的修改方式。