AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 387884
Accepted
MadHatter
MadHatter
Asked: 2012-05-11 04:29:51 +0800 CST2012-05-11 04:29:51 +0800 CST 2012-05-11 04:29:51 +0800 CST

“打开文件”ulimit:通过 limits.conf 控制

  • 772

我正在努力解决这个问题,但我不明白为什么它不起作用。我希望有人能阐明这一点,否则,请给我一些调查途径的建议。

我有一个 Red Hat 7.3 系统(不要问),希望增加wls81用户的打开文件限制。我以为我只是无法控制它,但它越来越看起来好像我只是遇到了我需要更改的用户的问题。我已将以下行添加到/etc/security/limits.conf:

wls81       soft    nofile      10100
wls81       hard    nofile      10240
madhatta    soft    nofile      10100
madhatta    hard    nofile      10240

pam_limits.so据我所知,正在被正确调用:

[madhatta@server madhatta]$ sudo grep limits /etc/pam.d/*
/etc/pam.d/login:session    required     /lib/security/pam_limits.so
/etc/pam.d/sshd:session    required     /lib/security/pam_limits.so
/etc/pam.d/su:session    required     /lib/security/pam_limits.so
/etc/pam.d/system-auth:session     required      /lib/security/pam_limits.so

当我以自己的身份 ssh 时,我得到了新的软限制,并且可以增加到硬限制:

desktop> ssh server
Last login: Thu May 10 13:20:13 2012 from a.b.c.d
[madhatta@server madhatta]$ ulimit -n 
10100
[madhatta@server madhatta]$ ulimit -n 10200
[madhatta@server madhatta]$ ulimit -n 
10200
[madhatta@server madhatta]$ ulimit -n 10300
bash: ulimit: cannot modify open files limit: Operation not permitted

但是当我以wls81用户身份登录时,我不能:

desktop> ssh wls81@server
Last login: Wed May  9 22:29:33 2012 from a.b.c.d
[wls81@server wls81]$ ulimit -n
1024
[wls81@server wls81]$ ulimit -n 10000
bash: ulimit: cannot modify open files limit: Operation not permitted

当我su -对每个用户时也会发生同样的情况。老实说,我不明白为什么这个用户不能ulimit重置它。有人有想法么?

linux redhat ulimit
  • 2 2 个回答
  • 7697 Views

2 个回答

  • Voted
  1. Best Answer
    MadHatter
    2012-05-18T13:10:43+08:002012-05-18T13:10:43+08:00

    好吧,谜团就解开了。我发现当我这样做时su - wls81我得到了 1024 的限制,但是当我刚刚这样做时su wls81我得到了新的、更高的限制。事实证明,wls81.bash_profile调用了另一个脚本,该脚本又从系统上的一个完全不同的用户调用了一个环境设置脚本,它执行了一个ulimit -n 1024.

    当我删除该行时,wls81 现在获得了新的限制。

    • 4
  2. Gnudiff
    2012-05-11T04:36:59+08:002012-05-11T04:36:59+08:00

    我认为您可能还需要检查并可能为内核中的打开文件设置最大文件描述符:

    sudo systcl fs.file-max
    

    并编辑 /etc/sysctl.conf 以使更改永久生效。

    • 0

相关问题

  • 多操作系统环境的首选电子邮件客户端

  • 你最喜欢的 Linux 发行版是什么?[关闭]

  • 更改 PHP 的默认配置设置?

  • 保护新的 Ubuntu 服务器 [关闭]

  • (软)Ubuntu 7.10 上的 RAID 6,我应该迁移到 8.10 吗?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve