Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8033377
  • 博文数量: 594
  • 博客积分: 13065
  • 博客等级: 上将
  • 技术积分: 10324
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-26 16:44
个人简介

推荐: blog.csdn.net/aquester https://github.com/eyjian https://www.cnblogs.com/aquester http://blog.chinaunix.net/uid/20682147.html

文章分类

全部博文(594)

分类: LINUX

2009-08-11 10:54:38

SuSE上的一些问题,可能需要另参考:http://blog.chinaunix.net/u2/64804/showart.php?id=2026903

limits.conf 文件实际是 Linux PAM(插入式认证模块,Pluggable Authentication Modules)中 pam_limits.so 的配置文件,而且只针对于单个会话。

limits.conf的格式如下:
username|@groupname type resource limit

username|@groupname:设置需要被限制的用户名,组名前面加@和用户名区别。也可以用通配符*来做所有用户的限制。

type:有 soft,hard 和 -,soft 指的是当前系统生效的设置值。hard 表明系统中所能设定的最大值。soft 的限制不能比har 限制高。用 - 就表明同时设置了 soft 和 hard 的值。

resource:
core - 限制内核文件的大小
date - 最大数据大小
fsize - 最大文件大小
memlock - 最大锁定内存地址空间
nofile - 打开文件的最大数目
rss - 最大持久设置大小
stack - 最大栈大小
cpu - 以分钟为单位的最多 CPU 时间
noproc - 进程的最大数目
as - 地址空间限制
maxlogins - 此用户允许登录的最大数目

要使 limits.conf 文件配置生效,必须要确保 pam_limits.so 文件被加入到启动文件中。查看 /etc/pam.d/login 文件中有:

ls /lib/security/pam_limits.so

    如果不作限制,可能一行代码就让你很惨了,甚至需要你重启一下。 
    你可以把下面这行代码复制粘贴到终端里执行测试一下是否需要限制 
     :(){ :|:; }; : 

例如我的:

* soft core 0
* hard rss 102400
truth soft nproc 2047
truth hard nproc 16384
truth soft nofile 1024
truth hard nofile 65536
truth hard cpu 10

同时编辑

sudo gedit /etc/pam.d/login

加入

#禁止调试文件
session required /lib/security/pam_limits.so 

系统重启后可尝试  :(){ :|:; }; : 
这时会出现bash: fork: 资源临时不可用
阅读(2118) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

aquester2009-08-11 11:01:01

要使 limits.conf 文件配置生效,必须要确保 pam_limits.so 文件被加入到启动文件中。查看 /etc/pam.d/login 文件中有: session required /lib/security/pam_limits.so