How to Check and Increase Linux Open File Limits (ulimit, sysctl)
This guide explains how to view and modify Linux's open file descriptor limits using commands like ulimit, sysctl, and by editing system configuration files, covering both system-wide and per‑user settings for improved application performance.
In Linux you can change the maximum number of open files. You can use the ulimit command, which allows you to control resources available to the shell or processes it starts.
Find Linux Open File Limit
# cat /proc/sys/fs/file-max
365004This value indicates the number of files that can be opened per login session; results may vary across systems.
For example, on a CentOS server the limit is set to 365004 .
Check Hard Limit in Linux
# ulimit -Hn
65535Check Soft Limit in Linux
# ulimit -Sn
65535To view hard and soft values for different users, switch users with su and compare.
Example:
# su rumenz
$ ulimit -Sn
1024 $ ulimit -Hn
1024How to Check System‑Wide File Descriptor Limit
If you run a server, some applications (e.g., MySQL/MariaDB or Apache) may require a higher open file descriptor limit.
You can increase the limit by editing the kernel parameter fs.file-max using sysctl at runtime.
For instance, to raise the limit to 500000 as root:
# sysctl -w fs.file-max=500000Check the current value with:
$ cat /proc/sys/fs/file-maxThese changes persist only until the next reboot; to make them permanent, edit /etc/sysctl.conf and add the line fs.file-max=500000 .
# vi /etc/sysctl.confAdd the following line:
fs.file-max=500000
You can adjust the number as needed.
# cat /proc/sys/fs/file-maxUsers must log out and log back in for changes to take effect; to apply immediately, run:
# sysctl -pSet User‑Level Open File Limit in Linux
The above examples show how to set a global limit; to apply limits per user, edit /etc/security/limits.conf as root.
# vi /etc/security/limits.confFormat:
<domain> <type> <item> <value>Example for user rumenz :
## Example hard limit for max opened files
rumenz hard nofile 4096
## Example soft limit for max opened files
rumenz soft nofile 1024Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
