Cent OS下修改用户打开文件数限制

如果有用户test,现在需要修改此用户打开文件数限制,步骤如下:
1 修改Linux下资源使用的配置文件,添加以下参数:
sudo vim /etc/security/limits.conf
test soft nproc 65534
test hard nproc 65534
test soft nofile 65534
test hard nofile 65534

参数说明:
nproc:用户可用的最大进程数量
nofile:用户可打开的最大文件总数
soft即是软限制,hard是硬限制。用户可以超过soft设置的值,但一定不能超过hard 的值。一般soft比hard小
test:代表用户,可以用 “*” 表示,代表所有用户

2 退出当前Sehll,重新登陆,输入下面的命令即可看见参数已经发现改变:
[test@localhost ~]$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 1821
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65534
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 65534
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

备注:如果是root用户可以在命令行直接修改,然后把ulimit -SHn 65534追加到/etc/profile文件中,普通用户在yum update升级之后,可能无法在命令行修改,可以直接修改配置文件。

猜你喜欢

转载自blog.51cto.com/zengwj1949/2120733
今日推荐