sysctl

From Wikipedia, the free encyclopedia

Template:Short description Script error: No such module "Distinguish".

Page Module:Message box/ambox.css has no content.Page Template:Multiple issues/styles.css has no content.

Page Module:Infobox/styles.css has no content.

sysctl
Template:Infobox software/simple
Written inC
EnginePage Template:Plainlist/styles.css has no content.Template:EditAtWikidata
Operating systemUnix-like (BSD)
TypeSystem configuration
WebsiteScript error: No such module "WikidataIB".
RepositoryPage Template:Plainlist/styles.css has no content.

Script error: No such module "Check for conflicting parameters".

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

BSD

In BSD, these parameters are generally objects in a 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 client, or the maximum number of processes on the system; or describe, enable or disable behaviors such as IP forwarding, security restrictions on the superuser (the "securelevel"), or debugging output.[1]

In OpenBSD and DragonFly BSD, sysctl is also used as the transport layer for the hw.sensors framework for hardware monitoring,[2] whereas NetBSD uses the ioctl system call for its sysmon envsys counterpart. Both sysctl and ioctl are the two system calls which can be used to add extra functionality to the kernel without adding yet another system call;[3] for example, in 2004 with OpenBSD 3.6, when the tcpdrop utility was introduced, sysctl was used as the underlying system call.[3][4] In FreeBSD, although there is no sensors framework, the individual temperature and other sensors are still commonly exported through the sysctl tree through Newbus, 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 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).

This feature first appeared in 4.4BSD. It has the advantage over hardcoded constants that changes to the parameters can be made dynamically without recompiling the kernel.

Historically, although kernel variables themselves could be modified through sysctl, the elements comprising the MIB 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, 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 under the Page Template:Mono/styles.css has no content./proc/sys directory (not to be confused with the Page Template:Mono/styles.css has no content./sys directory). This difference means checking the value of some parameter requires opening a file in a 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 in 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. In FreeBSD, NetBSD, OpenBSD, DragonFly BSD, and Darwin/Mac OS X, the parameter Page Template:Mono/styles.css has no content.net.inet.ip.forwarding can be set to Page Template:Mono/styles.css has no content.1 to enable this behavior. In Linux, the parameter is called Page Template:Mono/styles.css has no content.net.ipv4.ip_forward.

In most systems, the command Page Template:Mono/styles.css has no content.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 Page Template:Mono/styles.css has no content.parameter=1 can be added/rewritten to the file Page Template:Mono/styles.css has no content./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 Page Template:Mono/styles.css has no content./boot/loader.conf.

See also

Lua error in mw.title.lua at line 404: bad argument #2 to 'title.new' (unrecognized namespace name 'Portal').

References

Page Template:Reflist/styles.css has no content.

  1. ^ a b Lua error in package.lua at line 80: module 'Module:Citation/CS1/Utilities' not found.
  2. ^ Lua error in package.lua at line 80: module 'Module:Citation/CS1/Utilities' not found.
  3. ^ a b Lua error in package.lua at line 80: module 'Module:Citation/CS1/Utilities' not found.
  4. ^ Lua error in package.lua at line 80: module 'Module:Citation/CS1/Utilities' not found.
    • Lua error in package.lua at line 80: module 'Module:Citation/CS1/Utilities' not found.
  5. ^ a b Lua error in package.lua at line 80: module 'Module:Citation/CS1/Utilities' not found.
  6. ^ a b Lua error in package.lua at line 80: module 'Module:Citation/CS1/Utilities' not found.
  7. ^ Lua error in package.lua at line 80: module 'Module:Citation/CS1/Utilities' not found.
    • Lua error in package.lua at line 80: module 'Module:Citation/CS1/Utilities' not found.
  8. ^ Lua error in package.lua at line 80: module 'Module:Citation/CS1/Utilities' not found.

Template:DragonFly Lua error in package.lua at line 80: module 'Module:Navbox/configuration' not found. Lua error in package.lua at line 80: module 'Module:Navbox/configuration' not found. Lua error in package.lua at line 80: module 'Module:Navbox/configuration' not found.