On Tue, Jan 26, 2010 at 01:47:31PM -0500, Stephen Powell wrote: > On 2010-01-26 at 12:54:49 -0500, Vadkan Jozsef wrote: > > How can I set ulimit? > > when I give: > > > > ulimit -n 10240 > > > > ok, > > > > ulimit -n > > > > gives 10240. But. after a few minutes, it 1024 again! > > How can I set the ulimit to be permanently 10240? > > It would be important! :S > > Thank you :\ have a look at /etc/security/limits.conf I have 2 lines in there that are not commented @user hard nofile 2048 alex hard nofile 4198 > > man bash > /ulimit > > Description for the -n option says > > The maximum number of open file descriptors (most systems do not allow this value to be set) > > Apparently, one must be root to set ulimit. I tried it as a non-root user and got > > -bash: ulimit: open files: cannot modify limit: Operation not permitted > > But as the root user it works. I don't know how long you waited, but so far, my changes > are holding. I'm running bash version 3.2-4 under Lenny. However, the change holds only > for the current shell session and shell sessions descended from it. Other shell sessions > are not affected. The following will not work: > > $ su > Password: [enter password for root] > # ulimit -n 10240 > # ulimit -n > 10240 > # exit > $ ulimit -n > 1024 > > The su command invokes a new shell. You change the limit in the new shell. > The exit command takes you back to the previous shell. The limit in that > shell is unchanged. If you did something like this: > > [login as fred] > $ su > Password: [enter password for root] > # ulimit -n 10240 > # su fred > $ ulimit -n > 10240 > > Then a non-root user (fred) gets the new value for ulimit. > The first shell is the login shell. It's limit is still 1024. > The second (nested) shell is the root shell entered by "su" with no > arguments. It's limit starts as 1024 but is dynamically changed to 10240. > The "su fred" command invokes a third nested shell, which > inherits its ulimit value from the second nested shell. > It's limit is 10240. But this requires a couple of nested > shells, the second of which is still running as root, which > is a security exposure. All the user has to do is type "exit" > and he is now root! Maybe someone else knows a better way. > > -- At many levels, Perl is a "diagonal" language. -- Larry Wall in <199709021854.LAA12794@wall.org>
Attachment:
signature.asc
Description: Digital signature