在Ubuntu中,ulimit
命令用于設置用戶進程的資源限制,包括以下幾種常見的限制類型:
要查看當前的ulimit
設置,可以使用命令 ulimit -a
。
要臨時修改ulimit
設置,可以在當前shell會話中使用相應的ulimit
命令,例如:
ulimit -n unlimited
ulimit -t 300
要永久修改ulimit
設置,可以編輯用戶的配置文件(如~/.bashrc
或~/.profile
)或系統的配置文件(如/etc/security/limits.conf
)。例如,在limits.conf
文件中添加以下內容:
username soft nofile 65535
username hard nofile 65535
這將為用戶username
設置最大文件描述符數的軟限制和硬限制為65535。。
請注意,只有具有適當權限的用戶(通常是root用戶)才能修改系統范圍的ulimit
設置。