sysctl in Linux: read and set kernel parameters

Updated November 1, 2026

sysctl reads and changes kernel parameters that live under /proc/sys.

Syntax

sysctl parameter[=value]

Common cases

sysctl vm.swappiness               # read a parameter
cat /proc/sys/vm/swappiness        # the same thing as a file
sudo sysctl -w vm.swappiness=10    # change it until reboot
sysctl -a                          # every parameter at once

Sample output

$ sysctl vm.swappiness
vm.swappiness = 20
$ cat /proc/sys/vm/swappiness
20
$ sudo sysctl -w vm.swappiness=10
sysctl: setting key "vm.swappiness", ignoring: Read-only file system
vm.swappiness = 10
$ sysctl vm.swappiness
vm.swappiness = 20

How it works: a dot is a slash

A sysctl parameter name is just a path under /proc/sys with the dots turned into slashes: vm.swappiness is the file /proc/sys/vm/swappiness. So you can read a parameter with either cat or sysctl. sysctl -w changes a value, but only until reboot. To make a setting survive a reboot, you write it into /etc/sysctl.conf or a file in /etc/sysctl.d/. In the sandbox, writing kernel parameters is usually blocked, while reading them is fine.

Common mistakes

A failed write looks almost like a successful one. In the sandbox sudo sysctl -w vm.swappiness=10 prints two lines: sysctl: setting key "vm.swappiness", ignoring: Read-only file system, then vm.swappiness = 10. The second line is not a confirmation, it is an echo of what you asked for, and the exit code is 0. Check by reading it back: sysctl vm.swappiness still shows the old 20.

A typo in the name gives you a message about a file, not about a parameter. sysctl vm.swapiness answers sysctl: cannot stat /proc/sys/vm/swapiness: No such file or directory: the parameter name is a path, and the kernel found no such file. Look the real name up in the list: sysctl -a | grep swap.

As a normal user sysctl -a shows less than root sees. Some keys are closed for reading, each of them sends sysctl: permission denied on key 'kernel.cad_pid' to stderr, and its line never reaches stdout: 899 lines as the user, 904 under sudo. So sysctl -a | grep something can find nothing while the parameter does exist, and the errors land on your screen outside the pipeline.

Used in

You need this in the lesson The kernel via /proc. The theory is the chapter The Linux kernel at work.

See also

The /proc filesystem.

Try it

Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.