Home > linux基础 > 通过ulimit命令限制用户使用某些系统资源

通过ulimit命令限制用户使用某些系统资源

[[email protected] ~]# ulimit -a
core file size (blocks, -c) 0   【0代表没限制】
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited【可创建单一文件大小,也是没限制】
pending signals (-i) 7825
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024【可以同时打开的文件数量】
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 7825
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

敲个命令,设置下将可以创建的单一文件大小设置成10MB

[[email protected] ~]# ulimit -f 10240
[[email protected] ~]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) 10240
pending signals (-i) 7825
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 7825
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

下面咱们再创建下大小为20M的文件,显示失败。

[[email protected] ~]# dd if=/dev/zero of=123 bs=1M count=20
File size limit exceeded (core dumped)


若非注明,本博客内容均为原创或翻译自Linode Library,教程默认Centos为linux发行版,转载请注明转自linode中文教程www.linode.im。linode中文教程QQ群:185393826,一起讨论linode及linux,linode中文教程、linode代购、linode合租、linode推介、linode返佣、linode优惠。日本VPS、美国VPS、海外独立服务器代购均在linode.im。

Categories: linux基础 Tags: ,
  1. No comments yet.
  1. No trackbacks yet.