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 檢視ulimit報錯:
google 百度,翻譯都太拗口,簡潔的說:
ulimit是一個shell内置的指令 像cd ,不是一個獨立的程序,sudo以二進制方式運作,但是沒有ulimit的二進制方式,是以你運作錯誤。 應該在一個shell中運作。
本文轉自 憬薇 51CTO部落格,原文連結:http://blog.51cto.com/welcomeweb/2044982