Sysctl System Control Linux Commands

From Knowledge Center
Jump to: navigation, search

Setting Linux Kernel Paramaters temporarily using a one Liner

This will write a value to a variable:

$ sudo sysctl -w vm.max_map_count=262144

Display all the Variables:

$ sudo sysctl --all

Setting Temporary Linux Kernel Variables:

Note after reboot, these changes will be lost.

$ sudo sysctl -w vm.max_map_count=262144

To verify, lets read the value of the mentioned kernel parameter:

$ sudo sysctl -n vm.max_map_count
262144

Another method is to set it via the /proc partition:

# as root
~] echo '262145' > /proc/sys/vm/max_map_count

To verify the change:

$ sudo sysctl -n vm.max_map_count
262145

Setting Permanent Linux Kernel Variables:

$ sudo vi /etc/sysctl.conf

then set your key=value:

..
vm.max_map_count=262144
..

After saving, load the new values:

$ sudo sysctl -p /etc/sysctl.conf

Reading Linux Kernel Parameters:

$ sudo sysctl -n kernel.hostname
myhostname-01

$ sudo sysctl -n net.ipv4.conf.eth0.forwarding
1