转:http://stackoverflow.com/questions/17483723/command-not-found-when-using-sudo-ulimit
临时修改某用户(非root)的最大打开文件数
ulimit is a shell builtin like cd, not a separate program. sudo looks for a binary to run, but there is no ulimit binary, which is why you get the error message. You need to run it in a shell.
However, while you do need to be root to raise the limit to 65535, you probably don’t want to run your program as root. So after you raise the limit you should switch back to the current user.
To do this, run:
sudo sh -c "ulimit -n 65535 && exec su $LOGNAME"
and you will get a new shell, without root privileges, but with the raised limit. The exec causes the new shell to replace the process with sudo privileges, so after you exit that shell, you won’t accidentally end up as root again.
永久修改
编辑 sudo vi /etc/security/limits.conf 文件
用户名 soft nofile 1020000
用户名 hard nofile 102000
重起
用户名为 * 的时候表示所有的用户
本文介绍了如何临时及永久地修改非root用户的最大文件打开数限制。临时修改可通过sudo结合shell命令实现,而永久修改则需编辑/etc/security/limits.conf文件。

6733

被折叠的 条评论
为什么被折叠?



