SYSCTL(8)

๐Ÿ’– SYSCTL(8) โ€” the system manager's manual, but make it cute ๐Ÿ’–

okay bestie, sit down, hydrate, and let me tell you about sysctl from the System Manager's Manual (that's section 8, the big-kid admin section ๐Ÿ‘‘). this is the tool that pokes at your kernel's live settings, and honestly? it's giving main character energy.


โœจ NAME โœจ

sysctl โ€” configure kernel parameters at runtime ๐ŸŽ›๏ธ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

sysctl [option ...] variable[=value] ...

sysctl -p file-or-regexp ...

that's it, that's the whole vibe. read stuff, write stuff, or load a whole file of stuff. ๐Ÿซถ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so sysctl is what you use to modify kernel parameters at runtime. the parameters you can touch are the ones listed under /proc/sys/. Procfs is required for sysctl support in Linux, so no procfs = no dice, sorry. ๐Ÿ’€

and like, you can do both: use sysctl to read sysctl data and to write it. a little multitasking icon, we love to see it. โœจ


๐ŸŽ€ PARAMETERS ๐ŸŽ€

okay this section is doing a lot of work because it's got the arguments AND the options, so buckle up.

  • variable โ€” the name of a key to read from. an example is kernel.ostype. and ngl, the / separator is also accepted in place of a ., so you've got options. ๐Ÿ’…
  • variable=value โ€” to set a key, use the form variable=value where variable is the key and value is the value you're setting it to. heads up though: if the value contains quotes or characters which are parsed by the shell, you may need to enclose the value in double quotes. the shell is nosy like that. ๐Ÿ™ˆ
  • -n, --values โ€” use this option to disable printing of the key name when printing values. just the value, no name, no small talk.
  • -e, --ignore โ€” use this option to ignore errors about unknown keys. she's unbothered. โœจ
  • -N, --names โ€” use this option to only print the names. it may be useful with shells that have programmable completion. iykyk. ๐Ÿš
  • -q, --quiet โ€” use this option to not display the values set to stdout. silent but deadly (in a cute way).
  • -w, --write โ€” force all arguments to be write arguments and print an error if they cannot be parsed this way. no reading today, we're writing only. โœ๏ธ
  • -p[FILE], --load[=FILE] โ€” load in sysctl settings from the file specified, or /etc/sysctl.conf if none given. specifying - as filename means reading data from standard input. using this option will mean arguments to sysctl are files, which are read in the order they are specified. and plot twist: the file argument may be specified as regular expression. ๐Ÿ‘‘
  • -a, --all โ€” display all values currently available except deprecated and verboten parameters. (yes, "verboten." they really said that. iconic.)
  • --deprecated โ€” include deprecated parameters to --all values listing. peek at the ghosts if you must. ๐Ÿ‘ป
  • -b, --binary โ€” print value without new line.
  • --system โ€” load settings from all system configuration files. see the SYSTEM FILE PRECEDENCE section below. ๐Ÿ‘‡
  • -r, --pattern pattern โ€” only apply settings that match pattern. the pattern uses extended regular expression syntax. regex girlies rise. ๐ŸŒˆ
  • -A โ€” alias of -a
  • -d โ€” alias of -h
  • -f โ€” alias of -p
  • -X โ€” alias of -a
  • -o โ€” does nothing, exists for BSD compatibility. she's just here for the vibes. ๐Ÿซฅ
  • -x โ€” does nothing, exists for BSD compatibility. also just vibing. ๐Ÿซฅ
  • -h, --help โ€” display help text and exit.
  • -V, --version โ€” display version information and exit.

๐Ÿงš FILES ๐Ÿงš

these are the spots on the map bestie:

  • /proc/sys
  • /etc/sysctl.d/*.conf
  • /run/sysctl.d/*.conf
  • /usr/local/lib/sysctl.d/*.conf
  • /usr/lib/sysctl.d/*.conf
  • /lib/sysctl.d/*.conf
  • /etc/sysctl.conf

โญ NOTES โญ

๐ŸŒธ System file precedence

when you use the --system option, sysctl will read files from directories in the following list in given order from top to bottom. once a file of a given filename is loaded, any file of the same name in subsequent directories is ignored. first come, first served, no cap. ๐Ÿ

  • /etc/sysctl.d/*.conf
  • /run/sysctl.d/*.conf
  • /usr/local/lib/sysctl.d/*.conf
  • /usr/lib/sysctl.d/*.conf
  • /lib/sysctl.d/*.conf

all configuration files are sorted in lexicographic order, regardless of the directory they reside in. configuration files can either be completely replaced (by having a new configuration file with the same name in a directory of higher priority) or partially replaced (by having a configuration file that is ordered later).

the file /etc/sysctl.conf is read last, which means it can replace/override any parameters previously set in files in the listed directories. she gets the final word. ๐Ÿ’…

๐ŸŽ€ Deprecated parameters

base_reachable_time and retrans_time are deprecated. the sysctl command does not allow changing values of these parameters. users who insist to use deprecated kernel interfaces should push values to /proc file system by other means. for example:

echo 256 > /proc/sys/net/ipv6/neigh/eth0/base_reachable_time
ok so lowkey if you're insisting on this, you're on your own, bestie. do not come for me. ๐Ÿ˜ญ

๐Ÿ’œ Verboten parameters

certain kernel parameters should not be read due to side-effects and will be skipped by sysctl using the --all option.

  • stat_refresh โ€” this parameter returns no value but flushes per-cpu vm statistics.

๐Ÿ”ฅ EXAMPLES ๐Ÿ”ฅ

here's the group chat showing receipts:

/sbin/sysctl -a
/sbin/sysctl -n kernel.hostname
/sbin/sysctl -w kernel.domainname="example.com"
/sbin/sysctl -p/etc/sysctl.conf
/sbin/sysctl -a --pattern forward
/sbin/sysctl -a --pattern forward$
/sbin/sysctl -a --pattern 'net.ipv4.conf.(eth|wlan)0.arp'
/sbin/sysctl --pattern '^net.ipv6' --system

look at her go. ate and left no crumbs. ๐Ÿ‘‘


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

proc(5), sysctl.conf(5), regex(7)


๐Ÿ’€ REPORTING BUGS ๐Ÿ’€

please send bug reports to procps@freelists.org.


and that's the whole page, bestie!! this beauty is from procps-ng, dated 2024-07-19, and it lives in section 8 of the manual. go forth and configure your kernel, you absolute legend ๐Ÿซถโœจ๐ŸŽ€๐Ÿ’–

๐Ÿ“ฆ where this page comes from