Linux USES the Sysctl command to adjust kernel parameters

  • 2020-06-23 02:36:42
  • OfStack

preface

The sysctl command is used to dynamically modify kernel run parameters at kernel run time. The available kernel parameters are in the directory /proc/sys. It includes advanced options for TCP/IP stacks and virtual memory systems, which allow experienced administrators to improve compelling system performance. With sysctl you can read more than 500 system variables.

1. Common usage

List all the variables and view them


sysctl -a | less

Modify the value of a variable


sysctl -w  The variable name = A variable's 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 variable=value This is the syntax:


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

System variables can be modified using sysctl or by editing the sysctl.conf file. sysctl.conf looks a lot like rc. conf. It USES variable=value "To set the value. The specified value is set after the system enters multi-user mode. Not all variables can be set in this mode.

sysctl variables are usually set as strings, Numbers, or booleans. (Booleans use 1 for 'yes' and 0 for 'no').


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

2. Configuration of sysctl file

sysctl Settings defined in the sur/lib/sysctl d /, / run/sysctl d and/etc sysctrl d directory. 1 some software is set in the/usr/lib/sysctl d directory. To override the entire file system parameter, create a new file with the same name in the /etc/ sysctl.d directory and write your configuration. Create your own configuration as well.

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

The last

Some software is used to configure kernel parameters.

conclusion


Related articles: