6.10. The ulimit parameter

Linux itself has a Max Processes per user limit. This feature allows us to control the number of processes an existing user on the server may be authorized to have. To improve performance, we can safely set the limit of processes for the super-user root to be unlimited. Edit the .bashrc file vi /root/.bashrc and add the following line:

          ulimit -u unlimited
          
You must exit and re-login from your terminal for the change to take effect.


          [root@deep] /# ulimit -a
           

          core file size (blocks) 	1000000
          data seg size (kbytes)  	unlimited
          file size (blocks)	        unlimited
          max memory size (kbytes)	unlimited
          stack size (kbytes)	        8192
          cpu time (seconds)	        unlimited
          max user processes	        unlimited  (1)
          pipe size (512 bytes)	        8
          open files	                1024
          virtual memory (kbytes)	2105343
          
(1)
Make sure that when you type as root the command ulimit -a on your terminal, it shows unlimited next to max user processes.

Tip: You may also do ulimit -u unlimited at the command prompt instead of adding it to the /root/.bashrc file.

Increases the system limit on open files for instance a process on Red Hat 6.0 with kernel 2.2.5 could open at least 31000 file descriptors this way and a process on kernel 2.2.12 can open at least 90000 file descriptors this way. The upper bound seems to be available memory. To increases the number of open files to 90000 for the root account do the following: Edit the .bashrc file vi /root/.bashrc and add the following line:

          ulimit -n 90000
          
You must exit from your terminal and re-login for the change to take effect.


          [root@deep] /# ulimit -a
          

          core file size (blocks)	1000000
          data seg size (kbytes)	unlimited
          file size (blocks)	        unlimited
          max memory size (kbytes)	unlimited
          stack size (kbytes)	        8192
          cpu time (seconds)	        unlimited
          max user processes	        unlimited
          pipe size (512 bytes)	        8
          open files	                90000   (1)
          virtual memory (kbytes)	2105343
           

(1)
Make sure that when you type as root the command ulimit -a on your terminal, it shows 90000 next to open files.

Note: In older 2.2 kernels, though, the number of open files per process is still limited to 1024, even with the above changes.