debian - 如何在 Debian Stretch 中永久更改普通用户打开的文件(ulimit -n)?

标签 debian ulimit

我想永久更改系统打开文件设置,但它不起作用。

我的登录用户是普通用户,而不是root。我做了以下操作:

文件 /etc/sysctl.conf

$ grep 'fs.file-max' /etc/sysctl.conf
fs.file-max = 800000

文件 /etc/security/limits.conf

$ grep nofile /etc/security/limits.conf
#        - nofile - max number of open files
* soft nofile 655360
* hard nofile 655360

设置 /etc/security/limits.conf 在 CentOS/OpenSUSE 上有效,但在 Debian 中不起作用。

添加

session    required   pam_limits.so

进入文件/etc/pam.d/common-session{,-noninteractive},文件/etc/pam.d/login已经有了它。绝对路径是

/lib/x86_64-linux-gnu/security/pam_limits.so

重启后,执行ulimit -n,输出仍然是默认值1024

$ ulimit -n
1024

我应该怎样做才能使其生效?

最佳答案

这在 Debian 中不是问题。 这是 systemd + gnome 中的问题。 systemd选择不读取或使用limits.conf,gdm选择让systemd设置它的限制。 ssh sudo su tty 将使用 /etc/seecurity/limits.conf像平常一样。 查看此错误 systmd --user does not load limits from /etc/security/limits.d/ 在费多拉。在讨论中,这个解决方案对我有用。

创建文件/etc/systemd/system/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="324741574072030202021c415740445b51571c56" rel="noreferrer noopener nofollow">[email protected]</a>/limit.conf ,替换1000作为你的userId,在这个文件中设置限制,就像在systemd服务中一样:

[Service]
LimitNOFILE=655360

关于debian - 如何在 Debian Stretch 中永久更改普通用户打开的文件(ulimit -n)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46441602/

相关文章:

linux - 如果在 .vimrc 文件中回显,Vim 暂停

debian - Debian 10 Buster 中缺少 chromedriver

linux - 在 Linux 上设置文件数量限制的最正确方法是什么?

linux - Linux 中每个进程的最大打开文件数

c - 如何在 Mac OS X 上增加 C 中 "maximum open files"的限制

bash - Grep 文件中的日期并格式化它们

linux - 消耗带宽

Git、Debian、Apache 和智能 HTTP

linux - Netbeans 8.0.2 上的 ulimit -s

amazon-ec2 - 如何在 Amazon EC2 实例上增加 ulimit?