Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Oct 27 '10 at 11:37

This question came from our site for professional and enthusiast programmers.

    
1024 is a lot of open files...blogs.msdn.com/b/oldnewthing/archive/2007/03/01/1775759.aspx –  Chris Nava Oct 27 '10 at 15:28
    
@Chris Nava, That is nice in theory, but there are many services that will not reliably operate given that limit. Also 1024 isn't an OS limit is a resource limit placed on accounts. –  Zoredache Oct 27 '10 at 17:05
    
1024 isn't a lot of open file nowadays. –  Mark Wagner Oct 27 '10 at 22:37
add comment

4 Answers

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.

share|improve this answer
    
[root@seedbox01 ~]# cat /etc/passwd | grep seed seed:x:501:501::/home/seed:/bin/bash –  Andrey Zentavr Oct 28 '10 at 18:54
    
[root@seedbox01 ~]# cat /etc/pam.d/runuser #%PAM-1.0 auth sufficient pam_rootok.so session optional pam_keyinit.so revoke session required pam_limits.so session required pam_unix.so –  Andrey Zentavr Oct 28 '10 at 18:55
    
This is definitely the reason. I've deleted my answer as you were first :). –  Matthew Ife Oct 17 '13 at 19:07
add comment

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

...
# seed osuser - extended max number of open files
seed    hard    nofile    10240

# End of file

2 - in file '/etc/profile' or in '/home/seed/.bash_profile' add:

if [ $USER = "seed" ]; then
        ulimit -n 10240
fi
share|improve this answer
    
Suggestion #1 did not helped me, but #2 - yes. –  Andrey Zentavr Oct 28 '10 at 18:59
add comment

On linux systems, there are three places where file limits are set, each independent of the other:

  1. the kernel, as in /proc/sys/fs/file-max, controlled via sysctl fs.filemax or /etc/sysctl.conf

  2. the ulimit in the shell, as controlled by ulimit -n

  3. 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.

share|improve this answer
add comment

Using "ulimit -a" you see the soft limit, 1024 in redhat 5.8 is the default soft limit

vim /etc/security/limits.conf
user01  soft    nofile  1024
user01  hard    nofile  2048

ulimit -Sn
1024
ulimit -Hn
2048

reading proc

grep "Max open files" /proc/$$/limits
Max open files            1024                 2048                 files
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.