Skip to content

Instantly share code, notes, and snippets.

@somandubey
Created August 28, 2014 19:56
Show Gist options
  • Save somandubey/52bff8c7cc8639292629 to your computer and use it in GitHub Desktop.
Save somandubey/52bff8c7cc8639292629 to your computer and use it in GitHub Desktop.
How to increase ulimit in Linux

How to increase ulimit in Linux:

  • Step 1 (ulimit): open the sysctl.conf and add this line fs.file-max = 65536

      vi /etc/sysctl.conf   
    

    add following at end of file in above file:

      fs.file-max = 65536
    

save and exit.

  • Step 2 (ulimit):

      vi /etc/security/limits.conf
    

    Add following 4 lines in above file

      *  soft nproc  65535
      *  hard nproc  65535
      *  soft nofile 65535
      *  hard nofile 65535
    

save and exit check max open file ulimit

Example command to verify and sample output:

[root@localhost# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 127358
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
**OPEN FILES                      (-N) 65535**
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1024
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Increase max user processes in Linux

  • Step 1 (user processes):

      vi /etc/security/limits.conf
    

add following in above file

	*  soft nproc  65535
	*  hard nproc  65535
	*  soft nofile 65535
	*  hard nofile 65535
  • Step 2 (user processes): vi /etc/security/limits.d/90-nproc.conf

add following in above file

	*  soft nproc  65535
	*  hard nproc  65535
	*  soft nofile 65535
	*  hard nofile 65535

save and exit check the user max processes ulimit

[root@localhost# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 127358
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65535
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
**MAX USER PROCESSES              (-U) 65535**
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
@Altroo
Copy link

Altroo commented Apr 20, 2021

Thank's alot this helps, but i do have one question : why "65535" & not for example some higher value ?

@iaasweb
Copy link

iaasweb commented Jan 31, 2024

Thank's alot this helps, but i do have one question : why "65535" & not for example some higher value ?

Binary representation: The value "65535" can be represented as all 1s in a 16-bit binary number (1111111111111111). This makes it a convenient value for bitwise operations and internal data structures that use bit manipulation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment