Today’s TWEAK is a quick way to set the maximum number of open files on your Linux system. You might think that this would be useful for cutting back on the number of open files. In fact, it’s useful to system administrators running a system with a lot of users. You can, of course, decrease the allowable max open files, if you choose, though you probably won’t see any performance increase.
To set the maximum number of open files on your system, use:
echo “8192” > /proc/sys/fs/file-max
This is a tweak that acts directly on the /proc filesystem. We’ve talked about /proc in past issues. /proc, you’ll remember, is really a kernel abstraction in Linux. It allows sysadmins to communicate directly with the kernel. The above command does exactly that, sending the “8192” string to the kernel parameter called file-max in /proc/sys/fs. The default setting is 4096, so with this quick command, we’ve doubled the maximum number of open files on your system. More accurately, you’ve doubled the number of file handles available for identifying and tracking open files.
This is a change that would normally require a kernel recompile. It works well in the short-term, though, for maximizing the efficiency of your system under heavy loads.