2

I happened to see that on my Ubuntu 12.04 some resources of the root user is capped. I have not capped anything explicitly and my limits.conf as far as root user is concerned is empty. Here is the output of the ulimit -a on the root user

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 95931
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 95931
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

So I believe it is a default capping. So my question is what is the reason behind capping these resources of the root user by default? Now when I try to set the file limit to unlimited as root user by using the below command , I get an operation not permitted error.

ulimit -H -n unlimited

What prevents me from setting the limit to infinity and how safe it is to set it to infinity?

1 Answer 1

3
+100

Those default limits are hardcoded into the kernel source. Those limits are set for the init process by the kernel and other processes inherit it from init. See here.

Why you get an error when trying to set the number of open files to unlimited is likely because the system-wide setting is not unlimited, check it withcat /proc/sys/fs/file-max. See here:

file-max & file-nr:

The value in file-max denotes the maximum number of file- handles that the Linux kernel will allocate. When you get lots of error messages about running out of file handles, you might want to increase this limit.

You can change that system-wide limit if you run e.g. echo 300000 > /proc/sys/fs/file-max as root, or with sysctl -w fs.file-max=300000 as root. To make those changes permanent add a line similar to the following

fs.file-max=300000

to the /etc/sysctl.conf file, e.g by running echo "fs.file-max=300000" >> /etc/sysctl.conf as root.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .