su: cannot set user id: Resource temporarily unavailable问题解决

656 阅读1分钟

linux 下su切换用户失败

[root@localhost ~]# su - developer
su: cannot set user id: Resource temporarily unavailable

原因是linux操作系统默认最大允许进程数是1024,当前节点developer用户开启进程数超过了该数字
可以看到developer用户开启了1779个进程,已经超过了默认值

[root@localhost limits.d]# lsof -u developer | wc -l
1779

修改 /etc/security/limits.d/90-nproc.conf,将soft nproc的值从1024改为4096,完成

# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
 
*          soft    nproc     4096
root       soft    nproc     unlimited

保存后可以正常切换用户。

[root@localhost limits.d]# su - developer
[developer@localhost ~]$