免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: ailms
打印 上一主题 下一主题

问 :关于ulimit 的问题 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2007-07-31 01:18 |只看该作者

  1. [n7css@monitor n7css]$ cat /etc/security/limits.conf
  2. # /etc/security/limits.conf
  3. #
  4. #Each line describes a limit for a user in the form:
  5. #
  6. #<domain>        <type>  <item>  <value>
  7. #
  8. #Where:
  9. #<domain> can be:
  10. #        - an user name
  11. #        - a group name, with @group syntax
  12. #        - the wildcard *, for default entry
  13. #
  14. #<type> can have the two values:
  15. #        - "soft" for enforcing the soft limits
  16. #        - "hard" for enforcing hard limits
  17. #
  18. #<item> can be one of the following:
  19. #        - core - limits the core file size (KB)
  20. #        - data - max data size (KB)
  21. #        - fsize - maximum filesize (KB)
  22. #        - memlock - max locked-in-memory address space (KB)
  23. #        - nofile - max number of open files
  24. #        - rss - max resident set size (KB)
  25. #        - stack - max stack size (KB)
  26. #        - cpu - max CPU time (MIN)
  27. #        - nproc - max number of processes
  28. #        - as - address space limit
  29. #        - maxlogins - max number of logins for this user
  30. #        - priority - the priority to run user process with
  31. #        - locks - max number of file locks the user can hold
  32. #
  33. #<domain>      <type>  <item>         <value>
  34. #

  35. #*               soft    core            0
  36. #*               hard    rss             10000
  37. #@student        hard    nproc           20
  38. #@faculty        soft    nproc           20
  39. #@faculty        hard    nproc           50
  40. #ftp             hard    nproc           0
  41. #@student        -       maxlogins       4

  42. # End of file
  43. [n7css@monitor n7css]$
  44. [n7css@monitor n7css]$ ulimit -f 2000
  45. [n7css@monitor n7css]$ cat /etc/security/limits.conf
  46. # /etc/security/limits.conf
  47. #
  48. #Each line describes a limit for a user in the form:
  49. #
  50. #<domain>        <type>  <item>  <value>
  51. #
  52. #Where:
  53. #<domain> can be:
  54. #        - an user name
  55. #        - a group name, with @group syntax
  56. #        - the wildcard *, for default entry
  57. #
  58. #<type> can have the two values:
  59. #        - "soft" for enforcing the soft limits
  60. #        - "hard" for enforcing hard limits
  61. #
  62. #<item> can be one of the following:
  63. #        - core - limits the core file size (KB)
  64. #        - data - max data size (KB)
  65. #        - fsize - maximum filesize (KB)
  66. #        - memlock - max locked-in-memory address space (KB)
  67. #        - nofile - max number of open files
  68. #        - rss - max resident set size (KB)
  69. #        - stack - max stack size (KB)
  70. #        - cpu - max CPU time (MIN)
  71. #        - nproc - max number of processes
  72. #        - as - address space limit
  73. #        - maxlogins - max number of logins for this user
  74. #        - priority - the priority to run user process with
  75. #        - locks - max number of file locks the user can hold
  76. #
  77. #<domain>      <type>  <item>         <value>
  78. #

  79. #*               soft    core            0
  80. #*               hard    rss             10000
  81. #@student        hard    nproc           20
  82. #@faculty        soft    nproc           20
  83. #@faculty        hard    nproc           50
  84. #ftp             hard    nproc           0
  85. #@student        -       maxlogins       4

  86. # End of file
  87. [n7css@monitor n7css]$
复制代码


执行 ulimit -f 2000 后 /etc/security/limits.conf 没有任何变化,

况且该文件只有 root 可写,普通用户执行 ulimit 怎么可能修改该文件呢!

论坛徽章:
0
12 [报告]
发表于 2007-07-31 01:24 |只看该作者
普通用户不写,只是读。/etc/security/limits.conf 需要root用vi修改。
普通用户在自己的会话中可以做临时修改并不意味在要修改/etc/security/limits.conf

论坛徽章:
0
13 [报告]
发表于 2007-07-31 01:26 |只看该作者
/etc/security/limits.conf 要手动修改
格式是
写的很清楚了
#<domain>      <type>  <item>         <value>

<domain>就是你的username

论坛徽章:
0
14 [报告]
发表于 2007-07-31 01:29 |只看该作者
即使root在自己的会话中修改file-max,number of processes限制也不会修改/etc/security/limits.conf
你为什么会那么想?
呵呵

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
15 [报告]
发表于 2007-07-31 01:31 |只看该作者
[n7css@monitor n7css]$ ulimit -f 2000

这样的设定只对当前环境有效, 当注消shell后就没作用啦
/etc/security/limits.conf文件如楼上所说, 格式已经很清楚啦

论坛徽章:
0
16 [报告]
发表于 2007-07-31 01:34 |只看该作者
原帖由 yuhe27913 于 2007-7-31 01:29 发表
即使root在自己的会话中修改file-max,number of processes限制也不会修改/etc/security/limits.conf
你为什么会那么想?
呵呵



多谢 yuhe27913,俺明白了

不过还是不能解释为什么 su - 后仍然无法突破限制的问题啊

还有那些 ulimit -u 的问题又怎么解释呢?

论坛徽章:
0
17 [报告]
发表于 2007-07-31 01:43 |只看该作者
su - 是切换成root并取得root的环境变量啊。
ulimit -u是打印当前用户的the limited number of processes
ulimit -u 30执行不成功我倒是不清楚什么原因,手头也没有linux环境。

论坛徽章:
0
18 [报告]
发表于 2007-07-31 01:45 |只看该作者


su - 是切换成root并取得root的环境变量啊。


就是啊,既然 euid 都是 root 了,为什么无法突破 n7css 用户的  ulimit -f 限制

论坛徽章:
0
19 [报告]
发表于 2007-07-31 01:50 |只看该作者
倒,你再做一次测试贴上来吧。

论坛徽章:
0
20 [报告]
发表于 2007-07-31 01:54 |只看该作者
新鲜热辣的实验结果出炉了 !!!!!!! 还是不行 !!!!!


  1. [n7css@monitor n7css]$ ulimit -f 2000
  2. [n7css@monitor n7css]$ su -
  3. Password:
  4. [root@monitor root]# dd if=/dev/zero of=tmp_file bs=1K count=2048
  5. 文件大小超出限制
  6. [root@monitor root]#
  7. [root@monitor root]# echo $LANG
  8. zh_CN.GB18030
  9. [root@monitor root]#
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP