bash 如何重置硬限制?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18813336/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I reset the hard limits?
提问by Mencia
Trying to increase my stack size (the initial value was 8900(more or less)), I did the following:
试图增加我的堆栈大小(初始值为 8900(或多或少)),我执行了以下操作:
ulimit -s 10000
Then my stack size was 10000. Then I did:
然后我的堆栈大小是 10000。然后我做了:
ulimit -aH
From this point on, I could not increase the stack size, it would always say:
从现在开始,我无法增加堆栈大小,它总是说:
bash: ulimit: stack size: cannot modify limit: Operation not permitted
But I could decrease it. So then I did:
但我可以减少它。然后我做了:
ulimit -s 8000
And I had stack size 8000.
我的堆栈大小为 8000。
Now it comes the weird thing and this is that, being the "soft" limit which I am changing, since I did not do anything with sudo
, I should be able to go up to 10000 or 9000 again, but is not possible. This made me think that what I changed was the "hard" limit, since it is possible to decrease it, but not increase it, but I did not work from the root!
现在出现了奇怪的事情,这是我正在更改的“软”限制,因为我没有做任何事情sudo
,我应该能够再次上升到 10000 或 9000,但这是不可能的。这让我觉得我改变的是“硬”限制,因为可以减少它,但不能增加它,但我没有从根本上工作!
- Is there any possibility that I changed the "hard" limit without using
sudo
? - In case I changed the "hard" limit, how can I reset it to the initial default value?
- 我是否有可能在不使用的情况下更改“硬”限制
sudo
? - 如果我更改了“硬”限制,如何将其重置为初始默认值?
回答by nosid
If neither -S
nor -H
is used, both the soft and hard limit are set. The default hard limit for stack size is unlimitedon my machine:
如果既不使用-S
也不-H
使用,则同时设置软限制和硬限制。在我的机器上,堆栈大小的默认硬限制是无限的:
$ ulimit -aH | grep stack
stack size (kbytes, -s) unlimited
A regular use can change the hard and soft limits. The only restriction for non-root users is, that hard limits can not be increased.
经常使用可以更改硬限制和软限制。对非 root 用户的唯一限制是,不能增加硬限制。
A simple solution is to change only the soft limit by using ulimit -S -s 10000
.
一个简单的解决方案是使用 仅更改软限制ulimit -S -s 10000
。