Questions tagged [ulimit]

All about resource limits that can be set with the ulimit command

ulimit is a command to report and to modify certain resource limits. Some like have a built-in for ulimit.

Limits can be set for each process individually. Processes inherit their limits from their parents. One distinguishes between soft and hard limits. Hard limits can be increased only by privileged processes, i.e. by processes that have superuser privileges or at least the capability CAT_SYS_RESOURCE. Hard limits can be decreased by any process without special privileges. Soft limits can be changed arbitrarily with the constraint that the according hard limit cannot be exceeded.

Warning Resource limits are not a security mechanism. In particular, resource limits are only moderately effective against denial of service attacks by resource exhaustion. Since resource limits are individual to processes, they cannot be used to limit the resource consumption for all processes of an individual user or a group of users. (There are exceptions to this, see below). Instead, control groups should be used to enforce per-user total limits.

There are the following resource limits:

Memory limits

  • the maximum virtual memory size
  • the maximum size of the data segment
  • the maximum size of the process stack
  • the maximum core file size
  • the maximum amount of memory that can be locked into RAM
  • the maximum amount of memory that can be resident in RAM

Process limits

  • the maximum amount of time the process can occupy the CPU
  • the maximum priority that can be assigned to a process
  • the maximum number of processes with the same real user ID may be run concurrently
  • the maximum number of signals that can be queued for the process

Linux has also limits for real time priorities

File and IPC limits

  • The maximum number of files a process can have open simultaneously
  • The maximum number of locks a process can lease
  • The maximum size of files a process can create
  • The maximum pipe buffer size (this limit is a somewhat special since it is set with the fcntl() system call whereas all other limits are set with setrlimit())
  • The maximum number of bytes that all processes with the same real user ID may allocate for POSIX message queues

Use disk to limit the maximum space a user can occupy on a filesystem.

196 questions
245
votes
11 answers

Limit memory usage for a single Linux process

I'm running pdftoppm to convert a user-provided PDF into a 300DPI image. This works great, except if the user provides an PDF with a very large page size. pdftoppm will allocate enough memory to hold a 300DPI image of that size in memory, which…
Ben Dilts
  • 2,553
  • 3
  • 13
  • 5
202
votes
5 answers

do changes in /etc/security/limits.conf require a reboot?

Do changes in /etc/security/limits.conf require a reboot before taking effect? For example, if I have a script that sets the following limits in /etc/security/limits.conf, does this require a system reboot before those limits will take effect? *…
Alexej Magura
  • 4,356
  • 7
  • 26
  • 39
118
votes
2 answers

ulimit: difference between hard and soft limits

What is the difference between hard and soft limits in ulimit? For number of open files, I have a soft limit of 1024 and a hard limit of 10240. It is possible to run programs opening more than 1024 files. What is the soft limit for?
daniel kullmann
  • 9,427
  • 11
  • 38
  • 45
88
votes
5 answers

How to persistently control maximum system resource consumption on Mac?

Before Mavericks, I could use /etc/launchd.conf file to change maximum system resource consumption, for example: limit maxfiles 16384 unlimited limit maxproc 16384 unlimited It no longer works in Mavericks. What is the correct way to do it in the…
Howard
  • 5,149
  • 5
  • 30
  • 34
79
votes
1 answer

How to set ulimits on service with systemd?

How would you set a ulimit on a systemd service unit? This stackoverflow question explains that systemd ignores system ulimits What would the syntax look like to set the following ulimits? ulimit -c ulimit -v ulimit -m [Unit] Description=Apache…
spuder
  • 17,643
  • 36
  • 91
  • 119
63
votes
2 answers

Limits on the number of file descriptors

I'm trying to install 389-ds, And it gives me this warning: WARNING: There are only 1024 file descriptors (hard limit) available, which limit the number of simultaneous connections. I understand about file descriptors, but I don't understand about…
Rafael Adel
  • 1,261
  • 2
  • 13
  • 27
60
votes
3 answers

Why can't I crash my system with a fork bomb?

Recently I've been digging up information about processes in GNU/Linux and I met the infamous fork bomb : :(){ : | :& }; : Theoretically, it is supposed to duplicate itself infinitely until the system runs out of resources... However, I've tried…
Plancton
  • 687
  • 1
  • 5
  • 7
50
votes
5 answers

How can I increase open files limit for all processes?

I can use ulimit but I think that only affects my shell session. I want the limit increased for all processes. This is on Red Hat.
user5554
50
votes
3 answers

How to check ulimit usage

Is there any way to check the usage of the ulimits for a given user? I know that you can change ulimits for a single process when you start it up or for a single shell when running but I want to be able to "monitor" how close a user is to hitting…
hazmat
  • 609
  • 1
  • 5
  • 4
46
votes
4 answers

Modify ulimit (open files) of a specific process

Is it possible to change the soft - and hard limit of a specific process? In my case, my process is mongod and a lot of web resources tell me to simply execute: ulimit -n My current thoughts: How will the command know the limit of…
test
  • 569
  • 1
  • 4
  • 5
40
votes
4 answers

How to Throttle per process I/O to a max limit?

I'm looking for a way to limit a processes disk io to a set speed limit. Ideally the program would work similar to this: $ limitio --pid 32423 --write-limit 1M Limiting process 32423 to 1 megabyte per second hard drive writing speed.
Sepero
  • 1,569
  • 3
  • 20
  • 29
23
votes
2 answers

/etc/security/limits.conf not applied

I have /etc/security/limits.conf, that seems not been applied: a soft nofile 1048576 # default: 1024 a hard nofile 2097152 a soft noproc 262144 # default 128039 a hard noproc 524288 Where a is my username, when I run ulimit -Hn and ulimit -Sn,…
Kokizzu
  • 9,257
  • 12
  • 55
  • 82
23
votes
1 answer

Fixing ulimit: open files: cannot modify limit: Operation not permitted

I tested this on different GNU/Linux installations: perl -e 'while(1){open($a{$b++}, "<" ,"/dev/null") or die $b;print " $b"}' System A and D The first limit I hit is 1024. It is easily raised by putting this into /etc/security/limits.conf: * …
Ole Tange
  • 33,591
  • 31
  • 102
  • 198
19
votes
3 answers

ulimit & rlimit in Linux, are they the same thing?

I see people use the terms ulimit & rlimit interchangeably, can I say they are referring to the same thing?
Ryan
  • 413
  • 2
  • 4
  • 8
18
votes
1 answer

Meaning of the values for ulimit memlock flag

When I run docker and use the --ulimit memlock=-1:-1 option, what do the soft/hard values of -1 mean? Does it mean that I am allowing an unlimited amount memory to be locked by this container/process?
A P
  • 181
  • 1
  • 1
  • 4
1
2 3
13 14