Number of Files Opened: Difference between revisions

From Leo's Notes
This page was last edited on 24 February 2017, at 19:13.
No edit summary
m Text replacement - "<code>" to "{{code|"
Line 14: Line 14:
You may change this value by:
You may change this value by:
# cat <new value> > /proc/sys/fs/file-nr
# cat <new value> > /proc/sys/fs/file-nr
# Edit <code>/etc/sysctl.conf</code> so that there is a line
# Edit {{code|/etc/sysctl.conf</code> so that there is a line
#  fs.file-max = <new value>
#  fs.file-max = <new value>


== Per-User Settings ==
== Per-User Settings ==


You can see the limits set by running <code>ulimit</code> on the bash shell.
You can see the limits set by running {{code|ulimit</code> on the bash shell.
  # ulimit -n
  # ulimit -n


You can also see the per-user limits defined in <code>/etc/security/limits.conf</code>:
You can also see the per-user limits defined in {{code|/etc/security/limits.conf</code>:
  # cat /etc/security/limits.conf
  # cat /etc/security/limits.conf



Revision as of 19:13, 24 February 2017

Linux allows you to control how many opened file descriptor an user can have at any one time.

System-Wide Settings

To show the number of files opened on a system, run:

# cat /proc/sys/fs/file-nr
1536	0	793120

The fields are:

  1. Current number of opened files
  2. Number of free allocated file descriptors
  3. Maximum number of file descriptors for the whole system

You may change this value by:

  1. cat <new value> > /proc/sys/fs/file-nr
  2. Edit {{code|/etc/sysctl.conf so that there is a line
  3. fs.file-max = <new value>

Per-User Settings

You can see the limits set by running {{code|ulimit on the bash shell.

# ulimit -n

You can also see the per-user limits defined in {{code|/etc/security/limits.conf:

# cat /etc/security/limits.conf

See Also