You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

I've spent a fair amount of time googling this one - many of the answers were here on LQ - but they don't appear to be working for me.

I need to increase the number of open files for a "user" on a server.

Some of what I've tried:
1) Added
ulimit -n 9999
to /etc/profile

But then I get:
-bash: ulimit: open files: cannot modify limit: Operation not permitted

2) I also created a /etc/limits file with an entry like:
user N9999U9999
which doesn't appear to work either.

3) Also played with various incantations of ulimit w/ hard or soft limits from the command line.

I'm ssh'ing into the system and have confirmed that /etc/ssh/sshd_config has UsePrivilegeSeparation commented out. (Or does that have to be uncommented and set to no?)

This is for a service/daemon that runs as a specific user. So in a way I'm not even sure how I check that the running service is getting the privileges I'd like it to have - since it gets started from rc.local.

When I do ulimit -a after all of these tests, I see:
open files (-n) 1024

Any suggestions? This is a home-installed (my own install script) 10.2 w/ my own 2.6 kernel.
Thanks,
Eric

You were correct adding an entry to /etc/limits. What you have done is set the max number of open files to 9999 and the max number of processes to 9999 for the user called 'user'. The settings are per login - they are neither global nor permanent.

For your sshd_config file, all the values shown commented out are the default values that sshd runs with. To change the value being used, you will have to uncomment it and set it to no.

I get similar behaviour using ssh here. If I ssh directly as an account with elevated limits, those limits aren't set correctly. If I ssh as another user (not root, I can't login as root via ssh), then su to the account with the elevated limits, the limits are set. It looks like ssh ignores the /etc/limits settings.

There are quite a few sites that recommend turning off UsePrivilegeSeparation to get this working, but I haven't tested it because doing this on an internet accessible host is not a good thing. If your box is only accessible on a trusted network though...

Thanks Steve,
it looks like it is working now. I tweaked the start up to be:
su - user -c 'ulimit -n > /tmp/maxfiles ; /home/user/bin/<script> &'
and I can now confirm that it works okay when started from rc.local as well as from ssh.
-Eric