ulimit is a shell built in as cd , not a standalone program. sudo looking for an executable, but there is no ulimit binary, so you get an error. You need to run it in the shell.
However, although you need to be root in order to increase the limit to 65535, you probably do not want to run your program as root. Therefore, after you raise the limit, you must return 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 an increased limit. exec forces the new shell to replace the process with sudo privileges, so after exiting this shell you will not accidentally become root again.
andrewdotn Jul 05 '13 at 8:05 2013-07-05 08:05
source share