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 shell programs.
Syntax
ulimit [-aHS][-c <core file limit>][-d <data segment size>][-f <file size>][-m <memory size>][-n <file number>][-p <buffer size>][-s <stack size>][-t <CPU time>][-u <process number>][-v <virtual memory size>]
Parameters:
-a Display current resource limit settings.
-c <core file limit> Set the maximum value of the core file, in blocks.
-d <data segment size> Set the maximum value of the program data segment, in KB.
-f <file size> Set the maximum file size that the shell can create, in blocks.
-H Set the hard limit of resources, which is the limit set by the administrator.
-m <memory size> Set the upper limit of memory that can be used, in KB.
-n <file number> Set the maximum number of files that can be opened at the same time.
-p <buffer size> Set the size of the pipe buffer, in 512-byte units.
-s <stack size> Set the upper limit of the stack, in KB.
-S Set the flexible limit of resources.
-t <CPU time> Set the upper limit of CPU usage time, in seconds.
-u <process number> Set the maximum number of processes that a user can open.
-v <virtual memory size> Set the upper limit of virtual memory that can be used, in KB.
Example
Display system resource settings
[root@tutorialpro ~]# 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@tutorialpro ~]#
Set the upper limit of the number of single-user programs
[root@tutorialpro ~]# ulimit -u 500 //Set the upper limit of single-user programs
[root@tutorialpro ~]# 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@tutorialpro ~]#