I had the same issue with the error as this and this question (both of which I read and understood), the message being:
$ ulimit -n 20000
ulimit: bad limit: Operation not permitted
I encountered this issue on FreeBSD 8.3 after an upgrade from 7.3 and thought it may have had something to do with the upgrade.
I also had all sorts of issues running the command as root and could only run it as a standard user - which is what I wanted in any case.
The issue is that with FreeBSD the command is limit, not ulimit.
When I ran as a normal user:
%limits -n 20000
I got the exact result I wanted which was to increase the openfile limit from 11095 to 20000, or so I thought.
The output was:
Resource limits (current):
openfiles 20000
However when I ran the limit command again the limit is shown back at 11095.
How do I change either the hard/soft limit on a FreeBSD 8.3 box?
limitis the command in csh and tcsh.ulimitis the command in other shells.limitswill either run a command with modified limits, or give you an appropriate set of commands toevalin your shell to set limits. You probably wanteval \limits -e -S -n 20000`` – Mark Plotnick Apr 25 '14 at 01:59# evallimits -e -S -n 20000ulimit: Command not found.I get that answer as root, and as a normal user,evallimits -e -S -n 20000ulimit: bad limit: Operation not permitted– Deesbek Apr 25 '14 at 02:42limitsis guessing the wrong shell to output commands for. Try runninglimitdirectly:# limit desc 20000. In your normal-user example,limitsis working correctly butulimitis unable to raise the limit higher than the hard limit. You need to raise the hard limit for that normal user first, either by editing config files and logging in as that user again, or by runninglimit -h desc 20000as root and then usingsuto become the user. – Mark Plotnick Apr 25 '14 at 14:48