Operations 5 min read

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.

Open Source Linux
Open Source Linux
Open Source Linux
How to Check and Increase Linux Open File Limits (ulimit, sysctl)
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

365004
This 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

65535

Check Soft Limit in Linux

# ulimit -Sn

65535
To view hard and soft values for different users, switch users with su and compare.
Example:
# su rumenz
$ ulimit -Sn
1024
$ ulimit -Hn
1024

How 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=500000
Check the current value with:
$ cat /proc/sys/fs/file-max
These 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.conf
Add the following line:

fs.file-max=500000

You can adjust the number as needed.
# cat /proc/sys/fs/file-max
Users must log out and log back in for changes to take effect; to apply immediately, run:
# sysctl -p

Set 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.conf
Format:
<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    1024
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Operationslinuxsysctlfile descriptorulimitsystem limits
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.