開啟檔案的數量 - soft nofile 與 ULIMIT

開啟檔案的數量 - soft nofile 與 ULIMIT

供應商軟體配置需要在我們的 Linux 伺服器上進行以下設定:

xerox soft nofile 16384
xerox hard nofile 262144

在文件中

/etc/security/limits.conf

出於安全考量是否可以替換使用者bash_profile中的這些配置?

我可以用嗎

ulimit -n 262144

/home/xerox/.bash_profile

會一樣嗎?

更新
仍然很困惑,想知道
等效的命令是什麼

施樂軟 nofile 16384 和
施樂硬 nofile 262144

在 bash_profile 中

謝謝你!

答案1

若要變更您需要的軟限制ulimit -Sn。單獨使用時-n,您可以設定更受限制的兩個限制。用於ulimit -Hn減少硬限制。

然而,增加硬限制是 root 權限。那麼你的 bashrc 中的硬限制應該會低於limits.conf.

注意:硬限制最好在limits.conf. Achsh可以方便地更改 shell 並使用不讀取.bashrc. (或簡單地編輯.bashrc)。

答案2

其實不是,如果你設定了 .bash_設定檔每當使用者 xerox 登入時,.bash_profile 將被執行,並且 ulimit 將會被套用。假設如果伺服器重新啟動,則 ulimit 將不會自動設置,除非 xerox 使用者登入。設定於/etc/security/limits.conf將是永久的。

相關內容