"ulimit -n" on CentOS

On CentOS5, the default limit for open file is 1024. If we want to change the number of open file limit, (say, raise it to 50000), we can do the following:

$ sudo
# vi /etc/security/limits.conf

Enter the following lines to the file /etc/security/limits.conf:

*                hard    nofile          50000
*                soft    nofile          50000

Then save and exit the file. From a regular user's shell, run "ulimit -n", and you will see that the number of open file limit is now "50000":

$ ulimit -n
50000

The soft limit cannot be higher than the number in the hard limit.