sysctl - configure kernel parameters at runtime
在运行时配置内核参数。
选项
sysctl [-n] [-e] variable ...
sysctl [-n] [-e] [-q] -w variable=value ...
sysctl [-n] [-e] [-q] -p <filename>
sysctl [-n] [-e] -a
sysctl [-n] [-e] -A
描述
sysctl is used to modify kernel parameters at runtime. The parameters available are those listed under /proc/sys/. Procfs is required for sysctl(8) support in Linux. You can use sysctl(8) to both read and write sysctl data.
sysctl 用于在运行时修改内核参数。可用的参数是列在 /proc/sys/ 下的参数。在 Linux 中,sysctl(8) 支持需要 procfs。您可以使用 sysctl(8) 来读取和写入 sysctl 数据。
参数
variable
The name of a key to read from. An example is kernel.ostype. The '/' separator is also accepted in place of a '.'.
#要从中读取的键的名称。例如,kernel.ostype 就是一个示例。也可以使用 '/' 分隔符代替 '.'。
variable=value
To set a key, use the form variable=value, where variable is the key and value is the value to set it to. If the value contains quotes or characters which are parsed by the shell, you may need to enclose the value in double quotes. This requires the -w parameter to use.
#要设置一个键,使用变量=值的形式,其中变量是键,值是要设置的值。如果值包含由 shell 解析的引号或字符,则可能需要将值括在双引号中。
-n
Use this option to disable printing of the key name when printing values.
#使用此选项禁止在打印值时打印键名。
-e
Use this option to ignore errors about unknown keys.
#使用此选项忽略有关未知键的错误。
-N
Use this option to only print the names. It may be useful with shells that have programmable completion.
#使用此选项仅打印名称。在具有可编程补全功能的 shell 中可能会有用。
-q
Use this option to not display the values set to stdout.
#使用此选项不将值显示到标准输出。
-w
Use this option when you want to change a sysctl setting.
#当您想要更改 sysctl 设置时,请使用此选项。
-p
Load in sysctl settings from the file specified or /etc/sysctl.conf if none given. Specifying - as filename means reading data from standard input.
#从指定的文件或 /etc/sysctl.conf 中加载 sysctl 设置,如果未指定文件,则默认为 /etc/sysctl.conf。指定文件名为 - 意味着从标准输入读取数据。
-a
Display all values currently available.
#显示当前可用的所有值。
-A
Same as -a
#与 -a 相同
示例
/sbin/sysctl -a
/sbin/sysctl -n kernel.hostname
/sbin/sysctl -w kernel.domainname="example.com"
/sbin/sysctl -p /etc/sysctl.conf
文件
/proc/sys
/etc/sysctl.conf
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了