What parameters does ulimit have?
I see in examples that the -u
option is used with the ulimit
command, but I cannot find documentation that says what that option means. man ulimit
shows the manual for a system library function. What options does ulimit
have and what do they mean?
Solution 1:
The ulimit command is a built-in command which use the C functions described by man:
It's own help is included in Bash man page, accessible with man bash
.
You can list all available options with ulimit -h
,
and see their corresponding meaning using ulimit -a
which
list all available types of limitations and their current values,
depending of your system:
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 20
file size (blocks, -f) unlimited
pending signals (-i) 16382
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
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) unlimited
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
Solution 2:
ulimit
has to be a shell built-in since the limit it establishes applies to the shell itself as well as the programs it starts. The only portable argument is -f
(file size limit, in 512-byte units). Most shells have more option, you'll need to check the shell documentation to know exactly what they are. With portable shells such as bash and ksh, some unix variants may not support a limit even if the corresponding option is recognized by the shell.
Options that are supported by every shell I've seen:
-
-H
: Combine with other options to set or show the hard limit only. -
-S
: Combine with other options to set or show the soft limit only. -
-c
: maximum core file size (512-byte blocks) -
-d
: maximum heap (data segment) size (kB) -
-f
: maximum file size (512-byte blocks) -
-n
: maximum number of file descriptors -
-s
: maximum stack size (kB) -
-t
: maximum CPU time (s)
A few other very common options:
-
-a
: Display all limits. -
-m
: maximum physical memory size (kB) -
-v
: maximum virtual memory size (kB)