# how do i make ulimit settings... apply?

## adante

Hi, I am having some trouble applying limit settings

In my /etc/limits, I have tried the following entries

```
adante N4096

* N4096
```

Just for the heck of it I have also put into /etc/security/limits.conf

```

adante          soft    nofiles         4096

adante          hard    nofiles         8192

*               soft    nofiles         4096

*               hard    nofiles         8192

```

and also added

```
session    required     /lib/security/pam_limits.so
```

to /etc/pam.d/login

But when I login:

```
Using username "adante".

Authenticating with public key ""

Last login: Wed Mar 28 21:45:40 2007 from 192.168.1.67

adante@pveer ~ $ ulimit -a

core file size          (blocks, -c) 0

data seg size           (kbytes, -d) unlimited

file size               (blocks, -f) unlimited

max locked memory       (kbytes, -l) 32

max memory size         (kbytes, -m) unlimited

open files                      (-n) 1024

pipe size            (512 bytes, -p) 8

stack size              (kbytes, -s) 8192

cpu time               (seconds, -t) unlimited

max user processes              (-u) 16383

virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited

```

The limits still do not work.

What is the secret behind getting them to work? All the documentation tells me I need to re-login. I have done this, but still the file limit is 1024. Do I need to reboot? Physically login to terminal? Log out of all instances? Is this mentioned anywhere?

----------

## embobo

 *adante wrote:*   

> Hi, I am having some trouble applying limit settings
> 
> In my /etc/limits, I have tried the following entries
> 
> ```
> ...

 

I don't know what checks /etc/limits but the pam module checks /etc/security/limits.conf. The man page

of limits.conf doesn't give "nofiles" as an item.  Try "nofile".

Also, in /etc/pam.d/login you can add "debug" after "/lib/security/pam_limits.so". That may help troubleshooting.

You may need to reboot or kill all "login" processes.

If you are ssh'ing to the box you need to have "UseLogin yes" in /etc/ssh/sshd_config. Alternately,

you could put the pam stuff in /etc/pam.d/ssh or possibly /etc/pam.d/system-auth.

----------

## adante

thank you embobo!  that worked!

----------

## qriff

1.) edit /etc/security/limits.conf and add

```
*              hard    nofile          8192

*              soft    nofile          4096
```

2.) edit /etc/pam.d/system-login and add

```
session        required           pam_limits.so
```

2.1) (optional) edit /etc/pam.d/login and add

```
session        required           pam_limits.so
```

3.) logout and login, type

```

# ulimit -n

4096
```

4.) (optional) add "debug" after pam_limits.so

```
session        required           pam_limits.so debug
```

 and read debug output from /var/log/messages

```
 sshd[x]: Accepted publickey for user from xxx.xxx.xxx.xxx port xxxxx ssh2

pam_limits(sshd:session): reading settings from '/etc/security/limits.conf'

sshd[x]: pam_limits(sshd:session): process_limit: processing hard nofile 8192 for USER

sshd[x]: pam_limits(sshd:session): process_limit: processing soft nofile 4096 for USER

sshd[x]: pam_unix(sshd:session): session opened for user user by (uid=x)
```

----------

## Kalin

Also, if you are logging via ssh, check /etc/ssh/sshd_confg for `UsePAM yes` :-) That solved my problem.

----------

## masc

this setup broke for me after upgrading to pambase-20120417-r2.

when system starts up limits are not applied for services initially.

after restarting services (eg. apache) manually limits are applied correctly..

----------

