Ubuntu 18.04 LTS ulimit 修改不生效的问题

更改系统的 open files 最大限制,一般都是通过以下方法来做:

第一步:打开终端并敲入以下命令以打开一个配置文件

$: sudo gedit /etc/security/limits.conf

第二步:在打开的文件中增加以下几行配置并保存关闭

* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535

第三步:重启,并重新登录,打开终端后敲入以下命令进行验证

$ ulimit -a

open files (-n) 65536

这样几步就可大功告成!
但是,以上这些操作只能在 Ubuntu 16.04 及以下版本才能有效——到了 Ubuntu 18.04,却不起作用?百思不得其解,各种百度后无果,只好打开必应进行一番 E 文搜索,结果找到一篇老外的文章(https://superuser.com/questions/1200539/cannot-increase-open-file-limit-past-4096-ubuntu)。其中最有用的几句如下:

In Summary

  • If you want to increase the limit shown by ulimit -n, you should:
    Modify /etc/systemd/user.conf and /etc/systemd/system.conf with the following line (this takes care of graphical login):
DefaultLimitNOFILE=65535
  • Modify /etc/security/limits.conf with the following lines (this takes care of non-GUI login):
* hard nofile 65535
* soft nofile 65535

最后特别提醒大家一句,这三个地方的文件改好之后,一定要重启系统才得以生效哟!!

原文链接:https://blog.csdn.net/zhulx_sz/article/details/88309367

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值