相关疑难解决方法(0)

如何增加非 root 用户的打开文件限制?

这发生在 Ubuntu Release 12.04(精确)64 位内核 Linux 3.2.0-25-virtual

我正在尝试增加允许用户打开的文件数。这适用于我的 eclipse java 应用程序,其中 1024 的当前限制是不够的。

根据到目前为止我发现的帖子,我应该能够将行放入

/etc/security/limits.conf 像这样:

soft nofile 4096
hard nofile 4096
Run Code Online (Sandbox Code Playgroud)

增加允许所有用户打开的文件数。

但这对我不起作用,我认为问题与该文件无关。

对于所有用户,默认限制为 1024,无论 /etc/security/limits.conf 中的内容如何(更改该文件后我重新启动)

$ ulimit -n
1024
Run Code Online (Sandbox Code Playgroud)

现在,尽管 /etc/security/limits.conf 中的条目我无法增加:

$ ulimit -n 2048
Run Code Online (Sandbox Code Playgroud)

-bash: ulimit: open files: cannot modify limit: Operation not allowed 奇怪的是我可以向下改变限制,但不能向上改变 - 甚至回到低于原始限制的数字:

$ ulimit -n 800
$ ulimit -n
800

$ ulimit -n 900

-bash: ulimit: open files: cannot modify limit: Operation not permitted
Run Code Online (Sandbox Code Playgroud)

作为 root,我可以将限制更改为任何我想要的,向上或向下。它甚至似乎都不关心 /proc/sys/fs/file-max 中所谓的系统范围限制 …

ulimit

173
推荐指数
4
解决办法
49万
查看次数

标签 统计

ulimit ×1