Vous êtes sur la page 1sur 1

ulimit

ulimit is a shell builtin command used to show and set various restrictions on resource usage
for a shell. Among the limitations that can be set you find maximum file size, maximum core
file size and maximum size of resident memory. Though the restrictions are shell-independent,
the exact syntax depends on what shell you are running.

It's a good practice to set some of these limitations to prevent for instance a faulty shell script
to start unlimited copies of itself or to prevent users on the system to start processes that run
forever.

Warning: Typing ulimit may result in the output "unlimited". That is misleading, you may
have limits in place as you can find out with ulimit -a

ls3523:~ # ulimit
unlimited
ls3523:~ # ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
pending signals (-i) 4091
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) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 4091
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

In general, the command ulimit -$ (where $ is some letter) will return the current value of
the variable linked with $, while ulimit -$ NUMBER (again, where $ is some letter, and NUMBER
is generally an integer, or "unlimited") will set that variable. Of special note is the -a option,
which will display all limits for the system.
The -H and -S options are also special. -H will affect the "hard" limit, which is an absolute limit
on a resource. -S will affect the "soft" limit. The major difference between the two is that hard
limits can only be increased by root. Since the default for options is to affect both hard and
soft limits, adding -S to a command will allow returning the variable to the previous value
without root access.
Finally, all limits only apply to the thread in which they are set. For systemwide setting of
limits, try /etc/security/limits.conf

Examples
 ulimit -S -c 0 (Set the maximum filesize for core files to 0, as a soft limit. This will
prevent core dumps from forming, while allowing returning to the previous limit.)
 ulimit -f (Return the maximum file size.)
 ulimit -u unlimited (Remove all limits on the number of simultaneous user processes.)

Retrieved from "http://wiki.linuxquestions.org/wiki/Ulimit"

Vous aimerez peut-être aussi