This has probably been covered many times over, but I thought it might be handy to create a "reminder" for this very important system component.
Linux is pretty good at setting up a new system, but the addition or removal of programs over time can lead that system into becoming slow and sluggish. Linux is good, but no system is a mind-reader and self-configuring to cover all contingencies. I am, of course, referring to sysctl.conf
. This seemingly innocuous file is actually the make-it-or-break-it controller of the system! It does require root
privileges to modify, but it's likely world-readable, so feel free to take a look if you haven't before.
Pretty much anything your system does or can do, is configured here. Network settings, memory usage, buffers, etc. Some software packages will recommend (or require) modification of this file (I'm looking at you, VMware), but often it's only when some performance issue with your machine occurs that a change to this file can make a world of difference.
And here's the key that makes this a winner: You can make changes to your system on the fly without changing a thing, which makes testing a change a simple matter of issuing (as root) a single command. If your change doesn't make a difference, just reset the value (or reboot) and no harm is done. It's only when you want to make that change permanent (across reboots) that adding or changing a setting in sysctl.conf
will make it so, as this file is read in at system startup.
Here's an example, from my own experience: I used xrdp
on my Ubuntu MATE server to access it via an RDP client. This allows me to sit in one room while my server sits in another - even if the room I'm in is halfway around the world! But xrdp
has not always been a high-performing client-server system, and I've frequently experienced "freezing" or "jittering" when I'm connected. A little snooping around revealed that xrdp
sometimes needs more memory than is set in sysctl.conf
. I had actually set some values to accommodate software my company produced, but since I have a lot of memory on my server, giving more to the xrdp
function wasn't robbing Peter to pay Paul. The default settings for network send socket and receive socket are about 128k. So, I simply issued the command
sudo sysctl net.core.wmem.max
which showed me what the current value was. Sure enough, it was 1048576, which is 1MB. I then issued the command
sudo sysctl net.core.wmem.max=8388608
which is 8MB.
If I find the change useful, I can make it permanent by issuing:
sudo sysctl -w net.core.wmem_max=8388608
# (the '-w' means write it to disk)
It can pay to review the settings in the /etc/sysctl.conf
file, especially if you add or remove software frequently. I know of no software package that will change this file without your knowledge, and if you've removed some, those changes may persist.
Happy computing!