Linux command
ulimit 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Show all limits
ulimit -a
Show file size limit
ulimit -f
Set open files limit
ulimit -n [4096]
Show stack size
ulimit -s
Set unlimited stack
ulimit -s unlimited
Show hard limits
ulimit -Ha
说明
ulimit is a shell builtin that controls resource limits for the current shell session and any processes it spawns. It can set limits on CPU time, memory usage, open file descriptors, process count, file sizes, and other system resources. Each resource has a soft limit (the effective limit that can be raised by the user up to the hard limit) and a hard limit (the ceiling that only root can raise). Without the -H or -S flag, ulimit shows and sets the soft limit by default. These limits are important for preventing runaway processes from consuming all system resources and for configuring applications that need higher limits, such as database servers requiring more open file descriptors.
参数
- -a
- Display all current limits.
- -c
- Maximum size of core files (blocks).
- -d
- Maximum size of a process's data segment (kbytes).
- -f
- Maximum size of files written by the shell (blocks).
- -l
- Maximum size that may be locked into memory (kbytes).
- -m
- Maximum resident set size (kbytes).
- -n
- Maximum number of open file descriptors.
- -p
- Pipe buffer size (512-byte blocks).
- -s
- Maximum stack size (kbytes).
- -t
- Maximum amount of CPU time (seconds).
- -u
- Maximum number of user processes.
- -v
- Maximum amount of virtual memory (kbytes).
- -H
- Set or display hard limit.
- -S
- Set or display soft limit (default).
FAQ
What is the ulimit command used for?
ulimit is a shell builtin that controls resource limits for the current shell session and any processes it spawns. It can set limits on CPU time, memory usage, open file descriptors, process count, file sizes, and other system resources. Each resource has a soft limit (the effective limit that can be raised by the user up to the hard limit) and a hard limit (the ceiling that only root can raise). Without the -H or -S flag, ulimit shows and sets the soft limit by default. These limits are important for preventing runaway processes from consuming all system resources and for configuring applications that need higher limits, such as database servers requiring more open file descriptors.
How do I run a basic ulimit example?
Run `ulimit -a` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -a do in ulimit?
Display all current limits.