Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท Special Files and Directories

The /proc/sys directory

Reference for /proc/sys: how tunable kernel parameters map to files, how to read and write them, the sysctl command, persistence in sysctl.d, and common settings.

/proc/sys is the part of the /proc virtual filesystem that exposes the kernel's tunable parameters. Every file is one setting: reading it shows the current value, and writing to it (as root) changes the behavior of the running kernel immediately, with no reboot. Nothing here lives on disk; the files are windows into kernel memory.

The tree mirrors a dotted naming scheme. The parameter net.ipv4.ip_forward is the file /proc/sys/net/ipv4/ip_forward, and vm.swappiness is /proc/sys/vm/swappiness. The sysctl command is a convenience wrapper that translates between the two forms.

Terminal
cat /proc/sys/kernel/ostype
sysctl kernel.ostype
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward   # needs root

Try it

Bash Reading parameters as files

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Writing needs privileges (and may be blocked)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
sysctl [-n] name              # read one parameter
sysctl -a                     # list all parameters
sudo sysctl -w name=value     # change until reboot
sudo sysctl -p [file]         # load /etc/sysctl.conf or a file
sudo sysctl --system          # load every sysctl.d file
Part Description
kernel/ Core kernel settings: pid_max, hostname, random/, printk.
vm/ Memory management: swappiness, overcommit_memory, dirty_ratio.
net/ Networking: ipv4/ip_forward, core/somaxconn, ipv6/.
fs/ Filesystem limits: file-max, inotify/max_user_watches.
user/ User namespace and per-user limits.

Edge cases: values are text, usually one number or a few space-separated numbers. Some entries are read-only, some accept only specific values, and a write with a bad value fails with "Invalid argument".

Usage notes

  • Changes are temporary. A sysctl -w or echo write lasts until reboot. To keep a setting, put name = value in a file such as /etc/sysctl.d/90-custom.conf and run sudo sysctl --system.
  • Dots versus slashes. net.ipv4.conf.eth0.rp_filter is a path with eth0 as a directory. Interface names that contain dots (for example VLANs like eth0.100) swap the roles: sysctl net/ipv4/conf/eth0.100/rp_filter.
  • Common tunings: net.ipv4.ip_forward=1 for routers and container hosts, vm.swappiness to prefer RAM over swap, fs.inotify.max_user_watches for editors and file watchers, net.core.somaxconn for busy servers.
  • Containers. Many parameters are per network namespace, and most of /proc/sys is read-only inside an unprivileged container.
  • Do not guess. Wrong values for vm.overcommit_memory or kernel.panic can crash or hang a machine. Change one value at a time and note the old value.
  • Parameters versus /sys. /proc/sys holds kernel-wide tunables, while /sys exposes devices and drivers.