Abb*_*hia 19 linux ubuntu bash ulimit pam
我正在尝试为 ubuntu 机器上的所有用户提高打开文件描述符的最大值。
这个问题有点像这个问题的后续。
即使需要 pam_limits.so,ulimit 也不会读取打开的文件描述符limits.conf 设置
除了我在limits.conf中添加了所需的“root”条目
这是条目
* soft nofile 100000
* hard nofile 100000
root soft nofile 100000
root hard nofile 100000
Run Code Online (Sandbox Code Playgroud)
相关的pam_limits.so行在 /etc/pam.d/ 中的所有相关文件中已取消注释,并fs.file-max已在 /etc/sysctl.conf 中正确设置
然而,我仍然看到
abc@machine-2:/etc/pam.d$ ulimit -n
1024
Run Code Online (Sandbox Code Playgroud)
重启后。
可能是什么问题呢?
我的默认 shell 是 /bin/sh 并且我不能使用 chsh 来更改我的默认 shell,因为我的机器上的用户是通过某种分布式身份验证方案进行身份验证的。
小智 9
我有一个类似的问题,但只有 SSH 登录。本地登录(通过控制台)尊重/etc/security/limits.conf.
事实证明,当你设置:
UsePrivilegeSeparation yes
Run Code Online (Sandbox Code Playgroud)
在/etc/ssh/sshd_config文件中,然后 sshd 派生一个无特权的孩子来设置帐户的环境。因为这个孩子没有特权,那么 pam_limits.so 设置上限没有效果。
我一设置
UsePrivilegeSeparation no
Run Code Online (Sandbox Code Playgroud)
在/etc/ssh/sshd_config并退回 SSH 服务后,limits.conf 文件将通过 SSH 登录得到尊重。
在以 root 身份登录的 Redhat 服务器上
/etc/security/limits.conf
user01 - nofile 2048
Run Code Online (Sandbox Code Playgroud)
strace 命令以 root 身份记录
strace -o loglimit su - user01
Run Code Online (Sandbox Code Playgroud)
用其他 shell 打开 loglimit
grep "limit" loglimit
open("/lib64/security/pam_limits.so", O_RDONLY) = 6
..........
..........
open("/etc/security/limits.conf", O_RDONLY) = 3
read(3, "# /etc/security/limits.conf\n#\n#E"..., 4096) = 1823
open("/etc/security/limits.d", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = 3
setrlimit(RLIMIT_NOFILE, {rlim_cur=2*1024, rlim_max=2*1024}) = 0
Run Code Online (Sandbox Code Playgroud)
通过这种方式,我知道 pam_limits 已加载,并且 limit.conf 已读取,如果您的 pam_limits 已加载,但您仍然使用 ulimit -n 看到其他值,请检查您的 shell 配置文件,如 @etherfish 所说
我怀疑 ulimit 是由 /etc/profile 或 ~/.bashrc 应用的。事实上,您的系统有一个复杂的 pam,我可以确认没有出现问题。
我还要确认 /etc/security/limits.d/ 中没有按照 pam_limits(8) 中提到的方式解析错误文件。
我将调试参数添加到会话所需的 pam_limits.conf 行,然后在登录时观看 /var/log/auth.log 。
如果您的软限制是 1024,那么您的硬限制是多少?
su 应该使用 -l 参数为您提供全新的登录信息。
su -l -s /bin/bash
祝你好运。