Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use the Sysctl command to adjust kernel parameters in Linux

Shulou Source: shulou.com Published: 2022-06-01 21:09:47 09月15日 Update

In this issue, the editor will bring you about how to use the Sysctl command to adjust kernel parameters in Linux. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.

The sysctl command is used to dynamically modify kernel run parameters while the kernel is running, and the available kernel parameters are in the directory / proc/sys. It includes some advanced options for TCP/IP stacks and virtual memory systems, which allow experienced administrators to improve eye-catching system performance. You can read and set more than five hundred system variables with sysctl.

1. Common usage

List all variables and view

Sysctl-a | less

Modify the value of a variable

Sysctl-w variable name = variable value # sysctl-w vm.max_map_count=262144

Read a specified variable, such as kernel.msgmnb:

[xt@butbueatiful ~] $sysctl kernel.msgmnb kern.maxproc: 65536

To set a specified variable, use syntax such as variable=value directly:

[xt@butbueatiful ~] $sudo sysctl kernel.msgmnb=1024kernel.msgmnb: 1024

You can use sysctl to modify system variables, or you can modify system variables by editing the sysctl.conf file. Sysctl.conf looks a lot like rc.conf. It sets the value in the form of variable=value. The specified value is set after the system enters multi-user mode. Not all variables can be set in this mode.

The sysctl variable is usually set as a string, number, or Boolean. (Boolean means 1 for 'yes',' and 0 for 'no').

Sysctl-w kernel.sysrq=0sysctl-w kernel.core_uses_pid=1sysctl-w net.ipv4.conf.default.accept_redirects=0sysctl-w net.ipv4.conf.default.accept_source_route=0sysctl-w net.ipv4.conf.default.rp_filter=1sysctl-w net.ipv4.tcp_syncookies=1sysctl-w net.ipv4.tcp_max_syn_backlog=2048sysctl-w net.ipv4.tcp_fin_timeout=30sysctl-w net.ipv4.tcp_synack_retries=2sysctl-w net.ipv4.tcp_keepalive_time=3600sysctl-w net.ipv4.tcp_window_scaling=1sysctl-w net.ipv4.tcp_sack=1

2. About the configuration of sysctl files

The sysctl settings are defined in the sur/lib/sysctl.d/, / run/sysctl.d, and / etc/sysctrl.d directories. Some software settings are located in the / usr/lib/sysctl.d directory. To override the entire file system parameters, create a new file with the same name in the / etc/sysctl.d directory, and then write your configuration. It's the same with creating your own configuration.

In the / etc/sysctl.d directory, create a new file and write your own configuration.

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

The above is how to use the Sysctl command to adjust kernel parameters in Linux. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: Variables systems kernels parameters files directories configurations commands runs adjustments operating systems content Boolean patterns users software analysis advanced free eye-catching Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Microsoft Docker macOS MariaDB