Linux ulimit command
The Linux ulimit command is used to control the resources of shell programs.
ulimit is a shell built-in command that can be used to control the resources of programs executed by the shell.
Syntax
ulimit [-aHS][-c <core文件上限>][-d <数据节区大小>][-f <文件大小>][-m <内存大小>][-n <文件数目>][-p <缓冲区大小>][-s <堆叠大小>][-t <CPU时间>][-u <程序数目>][-v <虚拟内存大小>]
Parameters:
- -a Display current resource limit settings.
- -c <core file limit> Set the maximum size of the core file, in blocks.
- -d <data segment size> Set the maximum size of the program data segment, in KB.
- -f <file size> Set the maximum file size the shell can create, in blocks.
- -H Set the hard limit of resources, that is, the limit set by the administrator.
- -m <memory size> Specify the upper limit of usable memory, in KB.
- -n <number of files> Specify the maximum number of files that can be opened at the same time.
- -p <buffer size> Specify the size of the pipe buffer, in units of 512 bytes.
- -s <stack size> Specify the upper limit of the stack, in KB.
- -S Set the soft limit of resources.
- -t <CPU time> Specify the upper limit of CPU usage time, in seconds.
- -u <number of programs> The maximum number of programs a user can open.
- -v <virtual memory size> Specify the upper limit of usable virtual memory, in KB.
Examples
Display system resource settings
[root@example ~]# ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited file size (blocks, -f) unlimited pending signals (-i) 1024 max locked memory (kbytes, -l) 32 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 stack size (kbytes, -s) 10240 cpu time (seconds, -t) unlimited max user processes (-u) 4096 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited [root@example ~]#
Set the upper limit of the number of programs for a single user
[root@example ~]# ulimit -u 500 //设置单一用户程序上限 [root@example ~]# ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited file size (blocks, -f) unlimited pending signals (-i) 1024 max locked memory (kbytes, -l) 32 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 stack size (kbytes, -s) 10240 cpu time (seconds, -t) unlimited max user processes (-u) 500 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited [root@example ~]#Other Extensions
Linux Command Encyclopedia