Skip to main content
153 votes
Accepted

How to set ulimits on service with systemd?

The mappings of systemd limits to ulimit Directive ulimit equivalent Unit LimitCPU= ulimit -t Seconds LimitFSIZE= ulimit -f Bytes LimitDATA= ...
spuder's user avatar
  • 18.3k
139 votes

Limit memory usage for a single Linux process

On any systemd-based distro you can also use cgroups indirectly through systemd-run. E.g. for your case of limiting pdftoppm to 500M of RAM, starting with cgroupsv2, you can simply do: systemd-run --...
Hi-Angel's user avatar
  • 5,212
89 votes
Accepted

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

You probably have a Linux distro that uses systemd. Systemd creates a cgroup for each user, and all processes of a user belong to the same cgroup. Cgroups is a Linux mechanism to set limits on ...
Hkoof's user avatar
  • 1,687
58 votes

Modify ulimit (open files) of a specific process

To change the limits of a running process, you may use the utility command prlimit. prlimit --pid 12345 --nofile=1024:1024 What that does internally is to call setrlimit(2). The man page of prlimit ...
user7610's user avatar
  • 2,108
28 votes

How to check ulimit usage

Output the current user's percentage of open files, proc, and pending signals, by several inconvenient methods and standard tools: paste <(grep 'open files\|processes\|pending signals' \ ...
agc's user avatar
  • 7,273
28 votes

How calculate the number of files which can be passed as arguments to some command for batch processing?

Let xargs do the calculation for you. printf '%s\0' files/* | xargs -0 mv -t new_files_dir
Gilles 'SO- stop being evil''s user avatar
26 votes
Accepted

sudo: setrlimit(RLIMIT_CORE): Operation not permitted

a fix has been applied to sudo 1.8.31p1 and is already in 1.9 however this warning has a work around ... just issue echo "Set disable_coredump false" >> /etc/sudo.conf for details see https://...
Scott Stensland's user avatar
22 votes

Understanding the differences between pid_max, ulimit -u and thread_max

Sorry, the accepted answer is bad information on several fronts. /proc/sys/kernel/pid_max has nothing to do with the maximum number of processes that can be run at any given time. It is, in fact, the ...
David LaPorte's user avatar
22 votes
Accepted

/etc/security/limits.conf not applied

https://superuser.com/questions/1200539/cannot-increase-open-file-limit-past-4096-ubuntu/1200818#_=_ There's a bug since Ubuntu 16 apparently. Basically: Edit /etc/systemd/user.conf for the soft ...
daniel.gindi's user avatar
17 votes

How can I increase open files limit for all processes?

But if you're trying to increase the max number of open files of a service like MariaDB or something else (using systemd) you have to do directly in file .service /lib/systemd/system/<servicename&...
Matheus Baldasso's user avatar
16 votes

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

This won't crash modern Linux systems anymore anyway. It creates hoards of processes but doesn't really burn all that much CPU as the processes go idle. You run out of slots in the process table ...
Joshua's user avatar
  • 1,903
15 votes

/etc/security/limits.conf not applied

It is recommended to create /etc/systemd/*.d/ directories instead of editing /etc/systemd/system.conf and /etc/systemd/user.conf directly. Create a new file /etc/systemd/system.conf.d/limits.conf ...
Marc.2377's user avatar
  • 1,112
14 votes

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

The answer of fche is a very good hint, thanks for that, although it dosn't really solve the problem cause the question was to limit a process to a specific bandwidth. I would suggest something like ...
Benibr's user avatar
  • 267
13 votes
Accepted

What's the difference between setting open file limits in /etc/sysctl.conf vs /etc/security/limits.conf?

The difference is the scope, and how it's applied. Open file limits set via sysctls apply to the entire system, whereas limits set via /etc/security/limits.conf apply only to things that meet the ...
Austin Hemmelgarn's user avatar
13 votes

ulimit vs file-max

ulimit shows the per-process maximum. The two files under /proc shows system-wide numbers. From ServerFault: file-max is the maximum File Descriptors (FD) enforced on a kernel level, which cannot be ...
Kusalananda's user avatar
  • 341k
13 votes

Meaning of the values for ulimit memlock flag

Yes you are right. Check the definition of memlock here memlock maximum locked-in-memory address space (KB) This is memory that will not be paged out. It is frequently used by database management ...
vishnu viswanath's user avatar
12 votes
Accepted

Does nproc in limits.conf refers to number of processes or number of threads?

On Linux it refers to the number of threads. From setrlimit(2) (which is the system call used to set the limits): RLIMIT_NPROC The maximum number of processes (or, more precisely on Linux, ...
Stephen Kitt's user avatar
12 votes
Accepted

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

Check that /etc/ssh/sshd_config contains: UsePAM=yes and that /etc/pam.d/sshd contains: session required pam_limits.so In the comment below @venimus states the 1M limit is hardcoded: The ...
Ole Tange's user avatar
  • 36k
11 votes

Systemd LimitNOFILE capped to 4096

Late answer; limits.conf is not used when systemd is running (limits.conf is for non-systemd systems). The file you actually want is; /etc/systemd/system.conf - this is the global config. Then you ...
SiNGH's user avatar
  • 111
10 votes
Accepted

Why does a ulimit -u far greater than the number of processes I'm running cause problems?

On Linux threads count towards the ulimit -u count, but they don't show up normally with ps -A. You need to add the L flag. eg on my machine: % ps -A | wc -l 124 % ps -AL | wc -l 155 We can see ...
Stephen Harris's user avatar
10 votes
Accepted

How to cause "Argument list too long" error?

Using getconf ARG_MAX to generate a long list of x and calling an external utility with that as its argument would generate an "Argument list too long" error: $ /bin/echo $( perl -e 'print "x" x $...
Kusalananda's user avatar
  • 341k
10 votes
Accepted

Change the resource limits (ulimit / rlimit) of a running process

I've figured it out. On some kernels (e.g. 2.6.32+), at least on CentOS/RHEL, you can change the resource limits of a running process using /proc/<pid>/limits, e.g.: $ grep "open files" /proc/...
Bart's user avatar
  • 2,286
9 votes

How to persistently control maximum system resource consumption on Mac?

System limits Changing the limits in /etc/launchd.conf or /etc/rc.local is no longer supported for the recent macOS. See: Old Systems and Technology. Instead, you should create a new launch agent. ...
kenorb's user avatar
  • 21.4k
9 votes

Why does the following way not change core file limit size?

According to the manpage, ulimit "provides control over the resources available to the shell and to processes started by it". So the ulimit value is valid for the current shell. You are invoking ...
dr_'s user avatar
  • 30.4k
9 votes

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

Back in the 90's I accidentally unleashed one of these on myself. I had inadvertently set the execute bit on a C source file that had a fork() command in it. When I double-clicked it, csh tried to run ...
T.E.D.'s user avatar
  • 291
9 votes
Accepted

Chromium browser: exceed data ulimit

Why does chromium have different limits than all other programs? Chromium may look like a simple application but it is not, first there is the multi-threading which makes chromium run multiple ...
intika's user avatar
  • 14.7k
9 votes
Accepted

Can't set ulimit -n like I want to

# ulimit -n 1048576 # ulimit -n 2000000 bash: ulimit: open files: cannot modify limit: Operation not permitted # sysctl fs.nr_open fs.nr_open = 1048576 # sysctl fs.nr_open=2000000 fs.nr_open = 2000000 ...
ilkkachu's user avatar
  • 142k
8 votes

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

To quote @Tombart's answer These limits will be applied after reboot. If you want to apply changes without reboot, modify /etc/pam.d/common-session by adding this line at the end of file: ...
serv-inc's user avatar
  • 660
8 votes
Accepted

About ulimit/setrlimit and cgroup

All limits apply independently. When a process makes a request that would require going over some limit, the request is denied. This holds whether the limit is for a cgroup, per process, or per user. ...
Gilles 'SO- stop being evil''s user avatar

Only top scored, non community-wiki answers of a minimum length are eligible