# Sysctl

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Sysctl
> Markdown URL: https://mediated.wiki/source/Sysctl.md
> Source: https://en.wikipedia.org/wiki/Sysctl
> Source revision: 1321716781
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Unix-like software that manages kernel attributes

Not to be confused with [systemctl](/source/Systemctl).

This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages) This article relies excessively on references to primary sources. Please improve this article by adding secondary or tertiary sources. Find sources: "Sysctl" – news · newspapers · books · scholar · JSTOR (March 2015) (Learn how and when to remove this message) This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "Sysctl" – news · newspapers · books · scholar · JSTOR (November 2011) (Learn how and when to remove this message) (Learn how and when to remove this message)

sysctl Applying sysctl in a Linux system Written in C Operating system Unix-like (BSD) Type System configuration

**sysctl** is a software mechanism in some [Unix-like](/source/Unix-like) operating systems that reads and modifies the attributes of the system [kernel](/source/Kernel_(operating_system)) such as its version number, maximum limits, and security settings.[1] It is available both as a [system call](/source/System_call) for compiled programs, and an administrator command for interactive use and scripting. [Linux](/source/Linux) additionally exposes sysctl as a [virtual file system](/source/Virtual_file_system).

## BSD

In BSD, these parameters are generally objects in a [management information base](/source/Management_information_base) (MIB) that describe tunable limits such as the size of a shared memory segment, the number of threads the operating system will use as an [NFS](/source/Network_File_System_(protocol)) client, or the maximum number of processes on the system; or describe, enable or disable behaviors such as [IP](/source/Internet_Protocol) forwarding, security restrictions on the [superuser](/source/Superuser) (the "securelevel"), or debugging output.[1]

In [OpenBSD](/source/OpenBSD) and [DragonFly BSD](/source/DragonFly_BSD), sysctl is also used as the transport layer for the [hw.sensors](/source/Hw.sensors) framework for [hardware monitoring](/source/Hardware_monitoring),[2] whereas [NetBSD](/source/NetBSD) uses the [ioctl](/source/Ioctl) system call for its [sysmon envsys](/source/Sysmon_envsys) counterpart. Both sysctl and ioctl are the two [system calls](/source/System_call) which can be used to add extra functionality to the [kernel](/source/Kernel_(operating_system)) without adding yet another [system call](/source/System_call);[3] for example, in 2004 with OpenBSD 3.6, when the [tcpdrop](https://en.wikipedia.org/w/index.php?title=Tcpdrop&action=edit&redlink=1) utility was introduced, sysctl was used as the underlying system call.[3][4] In [FreeBSD](/source/FreeBSD), although there is no sensors framework, the individual temperature and other sensors are still commonly exported through the sysctl tree through [Newbus](https://en.wikipedia.org/w/index.php?title=Newbus&action=edit&redlink=1), for example, as is the case with the aibs(4) driver that's available in all the 4 BSD systems, including FreeBSD.[5][6][7]

In BSD, a [system call](/source/System_call) or system call wrapper is usually provided for use by programs, as well as an administrative program and a configuration file (for setting the tunable parameters when the system [boots](/source/Booting)).

This feature first appeared in [4.4BSD](/source/4.4BSD#4.4BSD_and_descendants). It has the advantage over hardcoded constants that changes to the parameters can be made dynamically without [recompiling](/source/Compiler) the kernel.

Historically, although kernel variables themselves could be modified through sysctl, the elements comprising the [MIB](/source/Management_information_base) of the sysctl tree were hardcoded at compile time, and as of 2019, it's mostly still the case in OpenBSD (with some exceptions like [hw.sensors](/source/Hw.sensors), which manages and provides its own dynamic subtree). FreeBSD has had "sysctl internal magic" for dynamic sysctl tree management since 1995; NetBSD has had its own implementation of a dynamic sysctl tree since December 2003.[5][6]

## Linux

In Linux, the sysctl interface mechanism is also exported as part of [procfs](/source/Procfs) under the /proc/sys directory (not to be confused with [the /sys directory](/source/Sysfs)). This difference means checking the value of some parameter requires opening a file in a [virtual file system](/source/Virtual_file_system), reading its contents, parsing them and closing the file. The sysctl system call does exist on Linux, but it has been deprecated and does not have a [wrapper function](/source/Wrapper_function) in [glibc](/source/Glibc); it is usually unavailable due to many distributions configuring the kernel without CONFIG_SYSCTL_SYSCALL; so it is not recommended for use.[8]

## Examples

When IP forwarding is enabled, the operating system kernel will act as a [router](/source/Router_(computing)). In [FreeBSD](/source/FreeBSD), [NetBSD](/source/NetBSD), [OpenBSD](/source/OpenBSD), [DragonFly BSD](/source/DragonFly_BSD), and [Darwin](/source/Darwin_(operating_system))/[Mac OS X](/source/Mac_OS_X), the parameter net.inet.ip.forwarding can be set to 1 to enable this behavior. In Linux, the parameter is called net.ipv4.ip_forward.

In most systems, the command sysctl -w *parameter*=1 will enable a certain behavior. This will persist until the next reboot. If the behavior should be enabled whenever the system boots, the line *parameter*=1 can be added/rewritten to the file /etc/sysctl.conf. Additionally, some sysctl variables cannot be modified after the system is booted. These variables (depending on the variable, the version and flavor of BSD) need to either be set statically in the kernel at compile time or set in /boot/loader.conf.

## See also

- [Computer programming portal](https://en.wikipedia.org/wiki/Portal:Computer_programming)
- [Linux portal](https://en.wikipedia.org/wiki/Portal:Linux)

- [hw.sensors](/source/Hw.sensors)

- [ioctl](/source/Ioctl)

## References

1. ^ [***a***](#cite_ref-n-sysctl-7_1-0) [***b***](#cite_ref-n-sysctl-7_1-1) ["sysctl(7) — system information variables"](http://bxr.su/n/share/man/man7/sysctl.7). *BSD Cross Reference*. [NetBSD](/source/NetBSD).

1. **[^](#cite_ref-sensors-ieee07_2-0)** Constantine A. Murenin (2007-04-17). [*Generalised Interfacing with Microprocessor System Hardware Monitors*](http://sensors.cnst.su/IEEE_ICNSC_2007). Proceedings of 2007 IEEE International Conference on Networking, Sensing and Control, 15–17 April 2007. London, United Kingdom: [IEEE](/source/Institute_of_Electrical_and_Electronics_Engineers). pp. 901–906. [doi](/source/Doi_(identifier)):[10.1109/ICNSC.2007.372901](https://doi.org/10.1109%2FICNSC.2007.372901). [ISBN](/source/ISBN_(identifier)) [978-1-4244-1076-7](https://en.wikipedia.org/wiki/Special:BookSources/978-1-4244-1076-7). IEEE ICNSC 2007, pp. 901—906.

1. ^ [***a***](#cite_ref-onlamp-36_3-0) [***b***](#cite_ref-onlamp-36_3-1) Federico Biancuzzi (2004-10-28). ["OpenBSD 3.6 Live"](https://web.archive.org/web/20041029232336/http://www.onlamp.com/lpt/a/5302). *[ONLamp](/source/ONLamp)*. [O'Reilly Media](/source/O'Reilly_Media). Archived from [the original](http://www.onlamp.com/lpt/a/5302) on 2004-10-29. Retrieved 2019-03-20.

1. **[^](#cite_ref-tcpdrop_4-0)** Markus Friedl (2004). ["tcpdrop.c"](http://bxr.su/o/usr.sbin/tcpdrop/tcpdrop.c). *BSD Cross Reference*. [OpenBSD](/source/OpenBSD). - "tcpdrop — drop a TCP connection". [*OpenBSD manual page server*](http://man.openbsd.org/tcpdrop.8).

1. ^ [***a***](#cite_ref-sensors-abc2009_5-0) [***b***](#cite_ref-sensors-abc2009_5-1) Constantine A. Murenin; [Raouf Boutaba](/source/Raouf_Boutaba) (2009-03-17). "8.3. Sensors framework in FreeBSD CVS". [*OpenBSD Hardware Sensors Framework*](https://web.archive.org/web/20100620015220/http://openbsd.org/papers/asiabsdcon2009-sensors-paper.pdf) (PDF). AsiaBSDCon 2009 Proceedings, 12–15 March 2009. Tokyo University of Science, Tokyo, Japan (published 2009-03-14). Archived from the original on 2010-06-20. Retrieved 2019-03-04.{{[cite conference](https://en.wikipedia.org/wiki/Template:Cite_conference)}}: CS1 maint: bot: original URL status unknown ([link](https://en.wikipedia.org/wiki/Category:CS1_maint:_bot:_original_URL_status_unknown))

1. ^ [***a***](#cite_ref-sensors-mmath_6-0) [***b***](#cite_ref-sensors-mmath_6-1) Constantine A. Murenin (2010-05-21). "8.3. Sensors framework in FreeBSD CVS". [*OpenBSD Hardware Sensors — Environmental Monitoring and Fan Control*](http://cnst.su/MMathCS) ([MMath](/source/Master_of_Mathematics#Canada) thesis). [University of Waterloo](/source/University_of_Waterloo): UWSpace. [hdl](/source/Hdl_(identifier)):[10012/5234](https://hdl.handle.net/10012%2F5234). Document ID: ab71498b6b1a60ff817b29d56997a418.

1. **[^](#cite_ref-aibs.4_7-0)** ["aibs(4) — ASUSTeK AI Booster ACPI ATK0110 voltage, temperature and fan sensor"](http://bxr.su/FreeBSD/sys/dev/acpi_support/atk0110.c). *BSD Cross Reference*. [FreeBSD](/source/FreeBSD). 2010. - "aibs -- ASUSTeK AI Booster ACPI ATK0110 voltage, temperature and fan sensor". [*FreeBSD Manual Pages*](https://www.freebsd.org/cgi/man.cgi?query=aibs&sektion=4&manpath=FreeBSD+8.2-RELEASE).

1. **[^](#cite_ref-8)** ["sysctl(2): read/write system parameters"](http://man7.org/linux/man-pages/man2/sysctl.2.html). [man7.org](/source/Michael_Kerrisk). 2017-09-15. Retrieved 2018-01-04.

## External links

- [sysctl(2) in OpenBSD](http://mdoc.su/o/sysctl.2)

- [sysctl(3) in FreeBSD, NetBSD, DragonFly BSD](http://mdoc.su/f,n,d/sysctl.3)

- [sysctl(7) in NetBSD](http://mdoc.su/n/sysctl.7)

- [sysctl(8) in *BSD](http://mdoc.su/-/sysctl.8)

- [sysctl(9) in FreeBSD, DragonFly and NetBSD](http://mdoc.su/f,d,n/sysctl.9)

- [sysctl(8)](https://man7.org/linux/man-pages/man8/sysctl.8.html) – [Linux](/source/Linux) Programmer's [Manual](/source/Man_page) – Administration and Privileged Commands

- [sysctl(2)](https://man7.org/linux/man-pages/man2/sysctl.2.html) – [Linux](/source/Linux) Programmer's [Manual](/source/Man_page) – System Calls

- [sysctl-explorer.net](https://sysctl-explorer.net) – An initiative to facilitate the access of Linux' sysctl reference documentation

v t e DragonFly BSD Project Operating system DragonFly BSD Light Weight Kernel Threads LWKT serializing tokens Kernel Normal Form OS-level virtualisation chroot jail vkernel File systems, storage AHCI NCQ autofs devfs disklabel fdisk HAMMER HAMMER2 LVM2 NFS NTFS NVMe procfs PUFFS tmpfs UFS soft updates Vinum VFS Firewalls, networking 802.11 drivers ALTQ Bluetooth BPF CARP ipfw NDIS netgraph PF Subsystems busdma DPorts ioctl kqueue moused OpenPAM sysctl hw.sensors systat SMBus People Matthew Dillon

v t e The FreeBSD Project FreeBSD FreeBSD Core Team FreeBSD Documentation License FreeBSD Foundation FreeBSD Ports Version History Subsystems Scheduling ALTQ ULE scheduler Virtualisation chroot jail bhyve Storage GEOM raid5 GBDE geli LVM2 vinum disklabel fdisk UFS Soft updates VFS ZFS Highly Available STorage Networking 802.11 drivers ALTQ Bluetooth BPF IPFilter ipfw Netgraph NDIS pf CARP pfsync SCTP Other busdma DTrace OpenPAM OpenBSM portsnap kqueue KLD moused systat People Matthew Dillon Jordan Hubbard Poul-Henning Kamp Mike Karels Ben Laurie Sam Leffler Marshall Kirk McKusick Diomidis Spinellis Robert Watson Dru Lavigne Derivatives open-source Chimera Linux XNU Darwin DesktopBSD DragonFly BSD FreeNAS FreeSBIE GhostBSD MidnightBSD m0n0wall OPNsense pfSense TrueOS GNU/kFreeBSD Gentoo/FreeBSD XigmaNAS proprietary Junos macOS, iOS, tvOS, and watchOS Nintendo Switch OS OpenServer 10 PlayStation 3 OS PlayStation 4 OS PlayStation Vita OS

v t e The NetBSD Project Operating system NetBSD Related projects pkgsrc netpgp pcc tnftp tcsh Notable subsystems Veriexec busdma DTrace envsys LKM Rump kernel File systems and storage bioctl CHFS disklabel fdisk LVM2 PUFFS tmpfs UFS WAPBL OpenZFS Firewalls and networking 802.11 drivers ALTQ Bluetooth CARP BPF IPFilter NPF PF pfsync

v t e The OpenBSD Project Operating system OpenBSD version history security features Related projects bio CARP doas httpd fdm LibreSSL mandoc OpenBGPD OpenIKED OpenNTPD OpenOSPFD OpenSMTPD OpenSSH PF pfsync sensors sndio spamd sudo tmux Xenocara cwm People Theo de Raadt Niels Provos Organizations OpenBSD Foundation Publications OpenBSD Journal

---
Adapted from the Wikipedia article [Sysctl](https://en.wikipedia.org/wiki/Sysctl) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Sysctl?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
