Ubuntu 修改文件最大打開數

設置bash

# 系統
echo 'fs.file-max = 65535' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
# 用戶
sudo tee -a /etc/security/limits.conf << EOF
*               hard    nofile          65535
*               soft    nofile          65535
root            hard    nofile          65535
root            soft    nofile          65535
EOF
# Systemd
sudo sed -i '/DefaultLimitNOFILE/c DefaultLimitNOFILE=65535' /etc/systemd/*.conf
sudo systemctl daemon-reexec

驗證ssh

# 打開新的終端
# ssh remote_user@host
# 查看系統限制
cat /proc/sys/fs/file-max
# 查看用戶硬限制
ulimit -Hn
# 查看用戶軟限制
ulimit -Sn
# 查看某進程的限制
cat /proc/PID/limits # 將 PID 替換爲具體的進程 ID
# 查看其餘用戶限制
su - www -c 'ulimit -aHS' -s '/bin/bash'
相關文章
相關標籤/搜索