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 ][-d <数据节区大小>][-f <文件大小>][-m <内存大小>][-n <文件数目>][-p <缓冲区大小>][-s <堆叠大小>][-t ][-u <程序数目>][-v <虚拟内存大小>]
Parameters:
- -a Display the current resource limit settings.
- -c
Set the maximum size of a core file, in blocks. - -d The maximum size of a program's data segment, in KB.
- -f
The largest file the shell can create, in blocks. - -H Set the hard limit for a resource, which is the limit imposed by the administrator.
- -m
Specify the upper limit of usable memory, in KB. - -n
Specify the maximum number of files that can be open at the same time. - -p
Specify the size of the pipe buffer, in units of 512 bytes. - -s
Specify the upper limit of the stack, in KB. - -S Set the soft limit for a resource.
- -t
Specify the upper limit of CPU usage time, in seconds. - -u
The maximum number of processes a user can start. - -v
Specify the upper limit of usable virtual memory, in KB.
Example
Display system resource settings
[root@runoob ~]# 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@runoob ~]#
Set the upper limit on the number of processes per user
[root@runoob ~]# ulimit -u 500 //设置单一用户程序上限
[root@runoob ~]# 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@runoob ~]#
Linux Command Reference