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?
limit
is the command in csh and tcsh.ulimit
is the command in other shells.limits
will either run a command with modified limits, or give you an appropriate set of commands toeval
in your shell to set limits. You probably wanteval `limits -e -S -n 20000`
# eval
limits -e -S -n 20000` ulimit: Command not found.` I get that answer as root, and as a normal user,eval
limits -e -S -n 20000` ulimit: bad limit: Operation not permitted`limits
is guessing the wrong shell to output commands for. Try runninglimit
directly:# limit desc 20000
. In your normal-user example,limits
is working correctly butulimit
is 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 20000
as root and then usingsu
to become the user.