在 CentOS 中,您可以使用以下方法之一来查看 ulimit 限制:
方法一:使用 ulimit
命令
ulimit -a
命令,然后按 Enter 键。示例输出:
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 123456
max locked memory (kbytes, -l) 64000
max memory size (kbytes, -m) unlimited
open files (-n) 4096
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 4096
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
方法二:查看 /etc/security/limits.conf
文件
sudo cat /etc/security/limits.conf
命令,然后按 Enter 键。* soft nproc 1024
* hard nproc 4096
* soft nofile 1024
* hard nofile 4096
这些规则定义了用户和组的资源限制。在这个例子中,*
代表所有用户,soft
是软限制,hard
是硬限制。nproc
是允许的最大进程数,nofile
是允许的最大文件数。
请注意,这些方法仅适用于当前 shell 会话。要永久更改 ulimit 设置,请修改 /etc/security/limits.conf
文件或使用 pam_limits.so
模块。