The sysctl command is used to modify Linux kernel variables at runtime. The variables are read and write from /proc/sys/ location using procfs. The syntax is as follows for to define variable:
variable=value
Read variable from command line
$ sysctl kernel.ostype
To see all variables pass the -a option:
$ sysctl -a $ sysctl -a | grep kernel $ sysctl -a | more
Sample outputs:
abi.vsyscall32 = 1 crypto.fips_enabled = 0 debug.exception-trace = 1 debug.kprobes-optimization = 1 dev.hpet.max-user-freq = 64 dev.mac_hid.mouse_button2_keycode = 97 dev.mac_hid.mouse_button3_keycode = 100 dev.mac_hid.mouse_button_emulation = 0 dev.raid.speed_limit_max = 200000 dev.raid.speed_limit_min = 1000 dev.scsi.logging_level = 0 fs.aio-max-nr = 65536 fs.aio-nr = 5352 fs.binfmt_misc.status = enabled fs.dentry-state = 1076563 1034844 45 0 0 0 fs.dir-notify-enable = 1 fs.epoll.max_user_watches = 418058 fs.file-max = 204059 fs.file-nr = 1664 0 204059 fs.inode-nr = 280530 70402 fs.inode-state = 280530 70402 0 0 0 0 0 fs.inotify.max_queued_events = 16384 fs.inotify.max_user_instances = 128 fs.inotify.max_user_watches = 8192 fs.lease-break-time = 45 fs.leases-enable = 1 fs.mqueue.msg_default = 10 fs.mqueue.msg_max = 10 fs.mqueue.msgsize_default = 8192 fs.mqueue.msgsize_max = 8192 fs.mqueue.queues_max = 256 fs.nfs.nfs_congestion_kb = 45760 fs.nfs.nfs_mountpoint_timeout = 500 fs.nfs.nlm_grace_period = 0 fs.nfs.nlm_tcpport = 0 fs.nfs.nlm_timeout = 10 ..... .. .. vm.page-cluster = 3 vm.panic_on_oom = 0 vm.percpu_pagelist_fraction = 0 vm.scan_unevictable_pages = 0 vm.stat_interval = 1 vm.swappiness = 60 vm.user_reserve_kbytes = 63568 vm.vfs_cache_pressure = 100 vm.zone_reclaim_mode = 0
Write variable from command line
The syntax is:
# sysctl -w variable=value
To enable packet forwarding for IPv4, enter:
# sysctl -w net.ipv4.ip_forward=1
Reload settings from all system configuration files
Type the following command to reload settings from config files without rebooting the box:
# sysctl --system
The settings are read from all of the following system configuration files:
- /run/sysctl.d/*.conf
- /etc/sysctl.d/*.conf
- /usr/local/lib/sysctl.d/*.conf
- /usr/lib/sysctl.d/*.conf
- /lib/sysctl.d/*.conf
- /etc/sysctl.conf
Persistent configuration
You need to edit the /etc/sysctl.conf file for setting system variables:
# vi/nano/mcedit /etc/sysctl.conf
Modify or add in the file. Close and save the file. To Load in sysctl settings from the file specified or /etc/sysctl.conf if none given, enter:
# sysctl -p
Similar Posts:
- how to disable ipv6 networking on debian / ubuntu
- how to setup proxy for apt in ubuntu / debian
- how to add / remove swap file on debian 9
- how to delete a lot of files in linux
- how to Find Linux Files by Name or Extension via command line
16,043
When someone writes an article he/she keeps the plan of a
user in his/her mind that how a user can know it. So that’s why this post is outstdanding.
Thanks!
Hello, Neat post. There is a problem with your website in web explorer, may check this?
IE still is the market chief and a large part of other people
will omit your wonderful writing because of this problem.