Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Debian Lenny. For every user, including root:

# cat /proc/sys/fs/file-max

# sysctl fs.file-max
fs.file-max = 262144

# ulimit -Hn

# ulimit -Sn

File /etc/security/limits.conf has no uncommented lines.

Where does it get that 1024?

share|improve this question
up vote 6 down vote accepted

The fs.file-max sysctl shows how many file handles can be allocated system-wide, while ulimit resource limits are per-process (or per-UID). The former is described in Documentation/sysctl/fs.txt:90:

file-max & file-nr:

The value in file-max denotes the maximum number of file-
handles that the Linux kernel will allocate. When you get lots
of error messages about running out of file handles, you might
want to increase this limit.

The 1024 files rlimit is not explicitly set anywhere; it's hardcoded into the kernel as the default value for pid 1, at include/asm-generic/resource.h:81:

 * boot-time rlimit defaults for the init task:
#define INIT_RLIMITS                                                    \
{                                                                       \
        [RLIMIT_NOFILE]         = {   INR_OPEN_CUR,   INR_OPEN_MAX },   \

which references INR_OPEN_CUR and INR_OPEN_MAX from include/linux/fs.h:26:

#define INR_OPEN_CUR 1024       /* Initial setting for nfile rlimits */
#define INR_OPEN_MAX 4096       /* Hard limit for nfile rlimits */

Other processes simply inherit the limit from init (or whatever is pid 1).

Why does /proc/1/limits on Debian report 1024 as both soft and hard nfile limit? I don't know: neither the sysvinit sources nor Debian kernel patches change it. It could be the initramfs scripts, maybe. (I run Arch, which has the 1024/4096 default.)

share|improve this answer

For the question @grawity brought up, this kernel commit can explain:

commit 0ac1ee0bfec2a4ad118f907ce586d0dfd8db7641
Author: Tim Gardner 
Date:   Tue May 24 17:13:05 2011 -0700

    ulimit: raise default hard ulimit on number of files to 4096

At lease in RHEL5.4 it's 1024/1024, and in RHEL6.2 it's 1024/4096.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .