在 CentOS 中,您可以使用 ulimit
命令來設置 shell 會話的限制
打開終端。
使用以下命令臨時設置 ulimit 值:
ulimit -n <新的限制值>
例如,要將文件描述符的限制設置為 1024,請執行:
ulimit -n 1024
請注意,此方法僅對當前 shell 會話有效。關閉會話或打開新窗口后,設置將丟失。
/etc/security/limits.conf
文件。首先,使用文本編輯器(如 vi
或 nano
)打開文件:sudo vi /etc/security/limits.conf
或者
sudo nano /etc/security/limits.conf
<username>
和 <usergroup>
):<username> soft nofile <新的軟限制值>
<username> hard nofile <新的硬限制值>
例如,要將文件描述符的軟限制設置為 1024,硬限制設置為 65536,請執行:
<username> soft nofile 1024
<username> hard nofile 65536
保存并關閉文件。
為了使更改生效,您需要注銷并重新登錄,或者重啟系統。
現在,您的 shell 會話將使用新的 ulimit 值。