how to increase the number of file descriptors in linux

user

to view a user’s limits:

ulimit -Hn -Sn

or, for another user:

echo  ulimit -Hn -Sn | sudo -u anotheruser -s

to adjust, add the user to /etc/security/limits.conf:

anotheruser  hard  nofile  16535
anotheruser  soft  nofile  16535

system

to view the system-wide limit on open file descriptors:

cat /proc/sys/fs/file-max

this can be changed with a the sysctl command. eg., to raise to 100,000:

sudo sysctl -w fs.file-max=100000

this setting can be preserved by adding an entry to /etc/sysctl.conf:

echo "fs.file-max = 100000" >> /etc/sysctl.conf

the setting can be loaded with:

sudo sysctl -p

redhat needs the following line to be added to /etc/pam.d/login for /etc/security/limits.conf to work:

session required pam_limits.so