I try to increase open file limit for certain user on CentOS 5.5 Linux. I added a new line to /etc/security/limits.conf:
seed hard nofile 10240
Then do test:
runuser -s /bin/bash - seed -c "ulimit -S -c 0>/dev/null 2>&1; ulimit -a"
0
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 8185
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
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) unlimited
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
And as you can see - open file limit is still 1024. If I set up the limit as 1000, it will be applied. So, I cannot setup the limit more than 1024.
How can I do that?? I need to set up the settings only for 1 user, not system-wide.
I suspect
runuser
doesn't go through PAM's "login" process that applies limits.conf, or maybe pam_limits.so is disabled. In Debian, at least,/etc/pam.d/su
has pam_limits.so commented out so that the limits are inherited from the user running su.To increase open file limit for certain user on CentOS 5.5 Linux:
1 - in file '/etc/security/limits.conf' add: - http://gerardnico.com/wiki/linux/limits.conf
2 - in file '/etc/profile' or in '/home/seed/.bash_profile' add:
On linux systems, there are three places where file limits are set, each independent of the other:
the kernel, as in /proc/sys/fs/file-max, controlled via sysctl fs.filemax or /etc/sysctl.conf
the ulimit in the shell, as controlled by ulimit -n
PAM, as set via /etc/security/limits.conf
The number that takes precedence and actually determines the limit on your processes is whatever is the LEAST of the above three.
Using "ulimit -a" you see the soft limit, 1024 in redhat 5.8 is the default soft limit
reading proc