Thứ Tư, 6 tháng 4, 2016

Sysctl setting - ip conntract

You must login as the root user to use any one of the following command on a Linux operating systems.

Display Linux kernel parameters

The syntax is:
# sysctl variable
####################################
### Display all sysctl variables ###
####################################
# sysctl -a
# sysctl -a | more
# sysctl -a | grep 'something'
# sysctl -a | grep memory

Sample outputs:
vm.memory_failure_early_kill = 0
vm.memory_failure_recovery = 1
vm.overcommit_memory = 0
To see value for kernel variable called kernel.hostname, enter:
# sysctl -n kernel.hostname

How do I set new values?

There are three methods to set new values for given kernel parameters as follows:

Method # 1: Setting value via procfs

You can use standard echo command to write data to variables (this temporary change):
# echo "value" > /proc/sys/location/variable

Method # 2: Temporary on the command line

Use sysctl command with -w option when you want to change a sysctl setting:
sysctl -w variable=value

Method # 3: Configuration file /etc/sysctl.conf

This is recommended way. First open /etc/sysctl.conf file, enter:
# vi /etc/sysctl.conf
Now add value:
variable = value
Close and save the changes. Type the following command to load sysctl settings from the file /etc/sysctl.conf file:
# sysctl -p
OR
# sysctl -p /etc/sysctl.conf
The last method will load settings permanently at boot time from /etc/sysctl.conf file. Read man page of sysctl for information:
$ man sysctl

Không có nhận xét nào:

Đăng nhận xét