Tune your Linux kernel with sysctl

Jack Wallen
May 13, 2010
Updated • Nov 28, 2012

Not many of today's Linux users remember the days when you could (and sometimes had to) compile your own kernel. If you had a special device or special needs for the kernel there was no other way to get it to work. Today most kernels work out of the box with most hardware. But there are times when you could squeeze out a bit more performance or even lighten your kernel on the fly. You can do that with the sysctl command.

This command allows you to turn on or off numerous kernel parameters on the fly or you can edit a specific file to tune those same parameters. Either way you can  modify all of the parameters listed in /proc/sys, so if you would like to see just how much you can modify, take a look at each of the subdirectories under the /proc/sys directory. For example, you can change the number of the maximum file descriptors on your machine by tuning the kern.maxfiles parameter.

NOTE: You will definitely want to exercise caution when toying with this command as it could, upon modifying any given parameter in the wrong way, cause data loss or worse.


The basic usage of the command is sysctl OPTIONS PARAMETER VARIABLE. The variable for a parameter will be in the form of either boolean, string, or numbers. You must run this command as either the root user or with the help of sudo. One of the first things  you might want to do is to issue the command sudo sysctl -a. This command will display all of the tunable variables on your machine. The list will look something like this:
kernel.sched_min_granularity_ns = 2000000
kernel.sched_latency_ns = 10000000
kernel.sched_wakeup_granularity_ns = 2000000
kernel.sched_shares_ratelimit = 500000
kernel.sched_shares_thresh = 4
kernel.sched_features = 15834235
kernel.sched_migration_cost = 500000
kernel.sched_nr_migrate = 32
kernel.sched_time_avg = 1000
kernel.timer_migration = 1
kernel.sched_rt_period_us = 1000000
kernel.sched_rt_runtime_us = 950000
kernel.sched_compat_yield = 0
kernel.panic = 0
kernel.core_uses_pid = 0
kernel.core_pattern = core
kernel.core_pipe_limit = 0
kernel.tainted = 0
kernel.latencytop = 0
kernel.real-root-dev = 0
kernel.print-fatal-signals = 0

In total, there are over 500 tunable parameters on an average Linux system. That's a lot to tune. If you want to examine that list more closely issue the command sudo sysctl -a > tunable and then open that file up with your favorite editor. Let's do this with something instantly useful. Say you want to re-enable <Ctrl><Alt><Del> that some distributions have disabled. First let's make sure your distribution has disabled this. Do this with the command:

sudo sysctrl kernel.ctrl-alt-del

What you should see output is:

kernel.ctrl-alt-del = 0

The above output does in fact inform you that this function has been disabled. Let's enable it. To do this you would issue the command:

sudo sysctl -w kernel.ctrl-alt-del=1

You should see the output:

kernel.ctrl-al-del = 1

Which tells you the command was successful. You can, of course, reset this to the original value with the command:

sudo sysctl -w kernel.ctrl-alt-del=0

Of course this is only a simple example of what you can tune with the sysctl command. Seeing as how there are over 500 tunable parameters, you could tune your kernel to meet some very specific needs.

Final thoughts

As with any tool that modifies a running kernel, make sure you exercise caution when using sysctl. You might want to practice this command on a non-production machine before you attempt to make any changes on a production machine. And start off simple. Modify some parameters that won't render your machine unbootable, your hard disc not writable, your network not reachable, etc.


Previous Post: «
Next Post: «


  1. SamD said on May 15, 2010 at 10:25 pm

    You have a typo in the example that shows how to check the value of kernel.ctl-alt-del. You’ve got ‘sysctrl’ vice ‘sysctl’.

    Good info to have.

  2. Dan Dart said on May 14, 2010 at 4:58 pm

    You forgot to mention: /etc/sysctl.conf is the default location for the configuration file so you don’t have to use sysctl -a to make yourself one, just edit that one.

  3. Dotan Cohen said on May 14, 2010 at 2:45 am

    Thanks, Evan. It seems that /sbin/ is not in the regular user’s path, and searching for the sysctl package in aptitude found nothing. Thanks for mentioning the path!

  4. Evan Carroll said on May 13, 2010 at 11:16 pm

    /sbin/sysctl is in the “procps” package which is required for ubuntu-minimal (it will be in any distro based on Ubuntu). It is also common in most distros using newer kernels.

  5. Dotan Cohen said on May 13, 2010 at 8:22 pm

    Nice, thanks! Anything like this for Ubuntu?

    1. Miguel Arvelo said on June 1, 2010 at 4:32 pm

      Last time I checked Ubuntu was a Linux distro…

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.