Tuesday, February 23, 2010

hard limit for "maximum open file descriptors"

In some cases when installing some software in Linux you might need to change the hard limit for "maximum open file descriptors". There are two levels of control on Linux maximum number of open files (or file descriptors), system limit and per-user/group/process limit. /etc/sysctl.conf is to set system-wide amount for kernel, /etc/security/limits.conf is to assign specific limits on per-user/group or process.

You may make changes by either issuing commands online or modifying the configuration files. Please bear in mind, online modification is usually temporary (the settings will be gone after reboot of system), change by modifying the configuration files is permanent.

Each user has per-user file descriptor limits. It includes soft and hard limits. hard limit is the absolute limit, user can set its soft limit freely to any value up to hard limit (use command: ulimit -n xxxx). Per-user limit defaults to 1024. Only root can increase the hard limit.

To change this you can add a line like the one below to your /etc/security/limits.conf
jolouwer hard nofile 65536

In this case I changed the hard limit for the user jolouwer

2 comments:

Anonymous said...

I've got a trouble in here, I modified the limits.conf file for number of files for a user

I put

user soft nofile 65536
user hard nofile 65536


but when I do

su - user

ulimit -n


it prints
1024

Chalons said...

we have the exact same problem, did you get it fixed? :D