See how to set ulimits quickly on Linux server for whole system and for individual user.

In this post, we will see how to set ulimits globally on the system and in case we want to set it user-wise.

Lets see it step by step.

 

1. Check current ulimit set on the system.

[root@ngelinux001 saket]# 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) 30385
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) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 100000
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
[root@ngelinux001 saket]#

 

2. Change ulimit temporarily in current shell.

root@ngelinux002 ~]# ulimit -n 16384
[root@ngelinux002 ~]# ulimit -n
16384

[root@ngelinux002 ~]# ulimit -u 8192
[root@ngelinux002 ~]# ulimit -u
8192

 

3. Put the settings in /etc/profile to set after every reboot.

root@ngelinux002 ~]# tail -5 /etc/profile
unset -f pathmunge

ulimit -n 16384
ulimit -u 8192
[root@ngelinux002 ~]# 

 

4. Define limits in /etc/security/limits.conf file to change system defaults.

[root@ngelinux002 ~]# tail /etc/security/limits.conf 
#ftp             hard    nproc           0
#@student        -       maxlogins       4

*	soft	nproc  8192
*	hard	nproc  8192
*	soft	nofile  16384
*	hard	nofile  16384
# End of file
[root@ngelinux002 ~]# 

 

4. Check the limit again after reboot.

[root@ngelinux002 ~]# 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) 4125961
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 16384
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) 8192
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
[root@ngelinux002 ~]# 

 

5. To set this for a specific user.
Set these parameters inside .profile file.

$ cat .profile
ulimit -n 16384
ulimit -u 8192
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments