06-B.7: Kernel Modules - Kernel Parameters
- Page ID
- 32791
Kernel Parameters
The /proc/sys directory contains a lot of useful and interesting files and directories. Many kernel settings can be manipulated by writing to files in the proc filesystem. A lot of important information can be retrieved from these files. This is especially useful when you are troubleshooting or fine tuning your Linux system.
The /proc/sys directory is divided into subdirectories:
Subdirectory | What it is |
---|---|
abi/ | Execution domains & personalities |
debug/ | <empty> |
dev/ | Device specific information (eg dev/cdrom/info) |
fs/ | Specific filesystems filehandle, inode, dentry and quota tuning binfmt_misc <Documentation/admin-guide/binfmt-misc.rst> |
kernel/ | Global kernel info / tuning miscellaneous stuff |
net/ | Networking stuff, for documentation look in: <Documentation/networking/> |
vm/ | Memory management tuning buffer and cache management |
user/ | Per user per user namespace limits |
The sysctl Command
The sysctl is a software utility that reads and modifies the attributes of the system kernel such as its version number, maximum limits, and security settings. It is available both as a system call for compiled programs, and an administrator command for interactive use and scripting.
Syntax:
sysctl [ OPTIONS ]
Options | Options Meaning |
---|---|
-a, --all | Display all values currently available. |
-e, --ignore | Use this option to ignore errors about unknown keys. |
-p [FILENAME}, --load[=FILENAME] | Load in sysctl settings from the file specified or /etc/sysctl.conf if none given. |
-r, --pattern pattern | Only apply settings that match pattern. |
-w, --write | Use this option when you want to change a sysctl setting. |
To see what the attributes look like use the -a option and the command will output ALL of the currently configured parameters. There are many more than the few shown in the example - the system that this was run on had a total of 936 parameters.
pbmac@pbmac-server $ sysctl -a
abi.vsyscall32 = 1
debug.exception-trace = 1
debug.kprobes-optimization = 1
dev.cdrom.autoclose = 1
dev.cdrom.autoeject = 0
dev.cdrom.check_media = 0
dev.cdrom.debug = 0
dev.cdrom.info = CD-ROM information, Id: cdrom.c 3.20 2003/12/17
The sysctl.conf File
The sysctl preload/configuration file can be created at /etc/sysctl.d/99-sysctl.conf. Current Linux distributions no longer maintain the /etc/sysctl.conf file. All of the configurations are contained in individual files in the /etc/sysctl.d/ directory.
Settings can be changed through file manipulation or using the sysctl utility. ForThis will change the current value of the parameter until the system is rebooted.
pbmac@pbmac-server $ sysctl kernel.sysrq=1
To preserve changes between reboots, add or modify the appropriate lines in /etc/sysctl.d/99-sysctl.conf or create an applicable parameter file in /etc/sysctl.d/.
Adapted from:
"Sysctl" by Multiple contributors, ArchWiki is licensed under CC BY-SA 4.0